Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
April 22, 2018, 09:08:06 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: myInt = [intNumber integerValue];  (Read 1651 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: 3114



« 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:  

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 ゥ 2009 classroomM.com. All rights reserved.