Re: Struggling with basics of Objective C
Re: Struggling with basics of Objective C
- Subject: Re: Struggling with basics of Objective C
- From: John Pannell <email@hidden>
- Date: Sun, 6 Mar 2005 14:03:41 -0700
Hi John-
In your code, the objects stored in the array are instances of NSNumber. As such they are not ints, which why your compiler is gagging. You can access the integer values of the numbers via NSNumber's intValue method:
int answer = [num1 intValue] + [num2 intValue];
Hope this helps!
John
On Mar 6, 2005, at 1:47 PM, John Hopkins wrote:
Hi Im new to all this and have had a few successes in making my programming do what I want it to do. Yet I am struggling with some of the basic stuff. ANSI C for example I can add two integers together quite simply. However in OBjC when I recall two integers from an array and assign them to a variable I keep getting the following warning message: assignment makes pointer from integer without a cast. What does it mean? How do I make it right? Please forgive my dimness I'm quite new to all this.
inputArray = [[NSMutableArray alloc] initWithCapacity:7];
x = [[sender selectedCell] tag];
[inputArray insertObject:[NSNumber numberWithInt:x] atIndex:0];
num1 = [inputArray objectAtIndex:0];
num2 = [inputArray objectAtIndex:1];
answer = num1 + num2;
John _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden