Re: NSString not working
Re: NSString not working
- Subject: Re: NSString not working
- From: Andy Lee <email@hidden>
- Date: Tue, 21 Apr 2009 00:53:00 -0400
Sorry for all the gobbledy-gook. I don't know how it got there.
--Andy
On Apr 21, 2009, at 12:40 AM, Andy Lee wrote:
--===============1542129808==
Content-Type: multipart/alternative;
boundary="Boundary_(ID_FctEvBkvFTrtTARG00O2AA)"
--Boundary_(ID_FctEvBkvFTrtTARG00O2AA)
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
On Apr 19, 2009, at 6:42 PM, Susan Granger wrote:
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.
How do you know str is nil? Are you looking at it in the debugger?
If you're using an NSLog, can you show us the NSLog statement?
Is this literally your EXACT code, or did you leave out or modify
something?
What output do you get if you try the following?
NSLog(@"my C string is [%s] with length %d", tmp, strlen(tmp));
NSLog(@"my NSString is [%@]", str);
NSLog(@"with UTF-8 I get [%@]", [NSString
stringWithUTF8String:tmp]);
--Andy
--Boundary_(ID_FctEvBkvFTrtTARG00O2AA)
Content-Type: text/html;
charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode:
space; =
-webkit-line-break: after-white-space; "><div><div>On Apr 19, 2009,
at =
6:42 PM, Susan Granger wrote:</div><blockquote type=3D"cite"><div>I
am =
unable to use NSString in my project.</div><div>But if i try it in
other =
new project it works fine.</div><div>can any one help with this =
?</div><div><br></div><div><span class=3D"Apple-style-span" =
style=3D"font-family: Monaco; font-size: 14px; ">char* tmp =3D =
"Blah";</span><br> </div><div><p style=3D"margin: 0.0px 0.0px 0.0px =
0.0px; font: 14.0px Monaco"><span class=3D"Apple-style-span" =
style=3D"color: rgb(92, 38, 153);"></span></p><div style=3D"margin-
top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 14px/normal Monaco; color: rgb(0, 116, 0); "> =
<br></div><p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px =
Monaco; color: #007400"><span class=3D"Apple-style-span"
style=3D"color: =
rgb(92, 38, 153);"></span></p><div style=3D"margin-top: 0px; =
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font:
normal =
normal normal 14px/normal Monaco; color: rgb(46, 13, 110); "> <span =
style=3D"color: #5c2699">NSString</span><span style=3D"color:
#000000">* =
str =3D [</span><span style=3D"color: #5c2699">NSString</span><span =
style=3D"color: #000000"> </span>stringWithCString<span
style=3D"color: =
#000000">:(</span><span style=3D"font: 18.0px Monaco; color: =
#aa0d91">const</span><span style=3D"color: #000000"> </span><span =
style=3D"font: 18.0px Monaco; color: #aa0d91">char</span><span =
style=3D"color: #000000">*)tmp </span>encoding<span style=3D"color: =
#000000">:</span>NSISOLatin1StringEncoding<span style=3D"color: =
#000000"> ];</span></div><div style=3D"margin-top: 0px; margin-
right: =
0px; margin-bottom: 0px; margin-left: 0px; font: normal normal
normal =
14px/normal Monaco; color: rgb(46, 13, 110); "><span =
class=3D"Apple-style-span" style=3D"color: rgb(0, 0, =
0);"><br></span></div><div><br =
class=3D"webkit-block-placeholder"></div><div style=3D"margin-top:
0px; =
margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font:
normal =
normal normal 14px/normal Monaco; "> After this, I get str =3D =
nil.</div></div></blockquote><br></div><div>How do you know str is
nil? =
Are you looking at it in the debugger? If you're using
an =
NSLog, can you show us the NSLog statement?</div><div><br></
div><div>Is =
this literally your EXACT code, or did you leave out or modify =
something?</div><div><br></div><div>What output do you get if you
try =
the following?</div><div><br></div><div>
NSLog(@"my C =
string is [%s] with length %d", tmp, =
strlen(tmp));</div><div><div> NSLog(@"my NSString
is =
[%@]", str);</div><div><div> NSLog(@"with UTF-8 I
get =
[%@]", [NSString =
stringWithUTF8String:tmp]);</div><div><br></div></div></div><div>--
Andy</d=
iv><br></body></html>=
--Boundary_(ID_FctEvBkvFTrtTARG00O2AA)--
--===============1542129808==
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit
_______________________________________________
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
--===============1542129808==--
_______________________________________________
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