Re: trouble getting c-chars from NSString
Re: trouble getting c-chars from NSString
- Subject: Re: trouble getting c-chars from NSString
- From: Shawn Erickson <email@hidden>
- Date: Thu, 31 Mar 2005 13:38:18 -0800
On Mar 31, 2005, at 1:12 PM, Daniel Child wrote:
Actually, your suggestion is precisely what I ended up using. However, I did have to use a C-String to paste the characters together because I did not find a method that does "stringFromChars." Here was my approach.
unichar c;
char noNums[100];
noNums[numNewChars++] = c;
A unichar is not a char. The former is 2 bytes (defined as an unsigned short) the later is 1 byte in size so you are losing data in the above operation.
printf("%s", [numFree cString]);
You can print an NSString directly using NSLog(@"%@", numFree), it is a bad idea to get a c string from an NSString since an NSString supports characters that cannot be expressed in a ASCII character set.
Can you restate exactly what you are trying to accomplish?
I am not talking about code but what your are trying to do with a string you have, what you want at the end, etc.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden