Re: NSString intValue
Re: NSString intValue
- Subject: Re: NSString intValue
- From: Christian Brunschen <email@hidden>
- Date: Tue, 12 Aug 2003 16:55:21 +0200 (MEST)
On Tue, 12 Aug 2003, Andreas Nfsby Rasmussen wrote:
>
Hi,
>
>
Something quite trivial which is starting to annoy me. I have a
>
NSString containing for example "1234", which I want to turn into an
>
int.
>
>
I fail to see why the following doesn't work but it always crashes with
>
... exited due to signal 10 (SIGBUS)
>
>
>
NSString *test = @"1234";
>
>
NSLog(@"test: %@", [test intValue]);
You are using '%@' in the format string to try to print an int - however,
'%@' is the formatting element specifying printing an _object_, and thus,
NSLog is trying to derefrence the value you pass in there (1234) as an
object pointer, which causes the bus error.
Try
NSLog(@"test: %d", [@"1234" intValue]);
instead.
>
Thank you in advance
Best wishes,
>
anr
// Christian Brunschen
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.