Amazon.com Widgets myInt = [intNumber integerValue];
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 19, 2013, 09:59:14 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Webcast Series Part II, Oct. 1 - 27
| | |-+  Questions and Discussion
| | | |-+  myInt = [intNumber integerValue];
Pages: [1]   Go Down
Print
Author Topic: myInt = [intNumber integerValue];  (Read 828 times)
John Shirley
Newbie
*
Posts: 47






« on: October 07, 2009, 12:06:03 PM »

Hi

Just wanted to ask a question on this

I understand that this line intNumber = [NSNumber numberWithInteger: 100];  assigns 100 which is an interger to the intNumber, but I am not too sure of this next part

myInt = [intNumber integerValue];

I know that its basically saying that myInt is equal to intNumber, but what does the next part do and mean "intergerValue".  why do you not just use myInt = intNumber;

Thanks
Logged
skochan
Administrator
Hero Member
*****
Posts: 3109







« Reply #1 on: October 07, 2009, 02:10:19 PM »

intNumber is an NSNumber object that is created and set to the integer value 100 by sending the numberWithInteger: message to the NSNumber class.   Just like you need to send the numerator method to a Fraction object to get the value of its numerator, so must you send the integerValue message to an NSNumber object to get the integer value stored in that object.   It's not directly accessible in the manner you described.

Cheers,

Steve Kochan
Logged
John Shirley
Newbie
*
Posts: 47






« Reply #2 on: October 15, 2009, 06:37:07 AM »

Sorry to come back to this again. 

So why do you have to have the myInt = [intNumber intgerValue]; only in the // integer value part of the code and not in the other sections like // long value  etc

Apologies if I am asking an obvious question
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.