|
|
NSData from NSString Question
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
I'm having a few problems converting a NSString to a NSData type.
doing NSData = NSString;, does the job, but generated a warning "assignment from distinct Objective - c type", but dumping to NSLog shows the output look to be correct. I've tried using various withEncoding types but end up with rubbish, the NSSting contains a file name with extension i need to write to.
Any ideas on the best way to accomplish this?
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
NSData *dataObject = [aString dataUsingEncoding:NSUnicodeStringEncoding];
(or substitute any of the list below for "NSUnicodeStringEncoding" depending on the encoding of your string)
Is this what you've tried?
Other encoding types (from the documentation)
enum {
NSASCIIStringEncoding = 1,
NSNEXTSTEPStringEncoding = 2,
NSJapaneseEUCStringEncoding = 3,
NSUTF8StringEncoding = 4,
NSISOLatin1StringEncoding = 5,
NSSymbolStringEncoding = 6,
NSNonLossyASCIIStringEncoding = 7,
NSShiftJISStringEncoding = 8,
NSISOLatin2StringEncoding = 9,
NSUnicodeStringEncoding = 10,
NSWindowsCP1251StringEncoding = 11,
NSWindowsCP1252StringEncoding = 12,
NSWindowsCP1253StringEncoding = 13,
NSWindowsCP1254StringEncoding = 14,
NSWindowsCP1250StringEncoding = 15,
NSISO2022JPStringEncoding = 21,
NSMacOSRomanStringEncoding = 30,
NSProprietaryStringEncoding = 65536
};
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
but dumping to NSLog shows the output look to be correct
The only reason this "works" is that it's still an NSString, not an NSData object.
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
AHH, o.k thanks guys, i'll give that a shot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|