Re: Struggling with basics of Objective C
Re: Struggling with basics of Objective C
- Subject: Re: Struggling with basics of Objective C
- From: John Hopkins <email@hidden>
- Date: Sun, 6 Mar 2005 21:15:11 +0000
Guys thanx, that explains why project builder didn't like what I was trying to do. It does seem to be an area of cocoa that I have come across so far that seems to complicate an otherwise simple thing. But then again I am a noob and was trying to add two classes together!!!
On 6 Mar 2005, at 21:06, Michael Hanna wrote:
if num1, num2 are int, then
num1 = [inputArray objectAtIndex:0];
num2 = [inputArray objectAtIndex:1];
would mean that you're trying to store the addresses of those objects into the ints. They're NSNumber objects, so why not do
num1 = [[inputArray objectAtIndex:0] intValue];
num2 = [[inputArray objectAtIndex:1] intValue];
After coding a couple of apps in Cocoa, I'm starting to wonder if NSNumber objects are any use at all actually.
Michael
On 6-Mar-05, at 3: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