Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

poppy11

macrumors newbie
Original poster
Oct 30, 2013
4
0
I am very new to Objective C, and am using the Smyth book Objective-C 2.0 Essentials-Third Edition. I'm working through the string stuff.

So why would I do something like ii=[string1 intValue];

when in the native 'C', I can just do ii=atoi(string1);

I'm not being sarcastic; I assume that the intValue method expands functionality in some way, or they wouldn't have bothered.

Sorry, trying to find the delete button. I believe that I've figured it out on my own.

In the book, he used an example like @"3456", which will work in either case, but assuming that string1 is an object, then atoi() wouldn't work.
 
Last edited:
String1 is not a C string. We can know this because it responds to method calls, it's a string object that returns the int value of the string as a response to the intValue call. The internal representation can be any of the available encodings.

atoi() only return the int value of primitive C strings, that is a byte string terminated by a null character.
 
String1 is not a C string. We can know this because it responds to method calls, it's a string object that returns the int value of the string as a response to the intValue call. The internal representation can be any of the available encodings.

atoi() only return the int value of primitive C strings, that is a byte string terminated by a null character.

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.