Re: NSString not working
Re: NSString not working
- Subject: Re: NSString not working
- From: Jeremy Pereira <email@hidden>
- Date: Mon, 20 Apr 2009 18:17:55 +0100
On 20 Apr 2009, at 09:14, Alexander von Below wrote:
My guess:
"If cString is not a NULL-terminated C string, or encoding does not
match the actual encoding, the results are undefined."
http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#/
/apple_ref/doc/uid/20000154-BAJCCGHJ
By inspection it is easy to tell tmp is null terminated and that it
conforms to the ISO Latin-1 encoding (seeing as it only contains ASCII
characters). Therefore, one would expect it to work....
... and indeed it does. The following:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
char* tmp = "Blah";
NSString* str = [NSString stringWithCString:(const char*)tmp
encoding:NSISOLatin1StringEncoding ];
NSLog (@"str = %@\n", str) ;
[pool release];
return 0;
}
gives me the following output:
[Session started at 2009-04-20 18:12:25 +0100.]
2009-04-20 18:12:26.112 Perform[17260:10b] str = Blah
The Debugger has exited with status 0.
Alex
Am 20.04.2009 um 00:42 schrieb Susan Granger:
Hi,
I am unable to use NSString in my project.
But if i try it in other new project it works fine.
can any one help with this ?
char* tmp = "Blah";
NSString* str = [NSString stringWithCString:(const char*)tmp
encoding:NSISOLatin1StringEncoding ];
After this, I get str = nil.
Thanks & Regards
Susan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden