Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Assignment makes pointer from integer without a cast
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Assignment makes pointer from integer without a cast



Hi Marx,

This warning pops up when you're assigning, as the warning says, a value of one type to a variable of another type. Having not yet seen your header file, I can't be 100% certain of this, but the warning strongly indicates that your "age" instance-variable (or ivar) is in fact *not* typed as "int", but as some kind of pointer, perhaps as int* for example. But it's hard to say without seeing your header file (I'm sure you understand why we can't just take your word for it, and why we need to see the code verbatim).

-Steven


On Fri, Mar 5, 2010 at 10:53 AM, Marx Bievor <email@hidden> wrote:
Hi there,

I'm relatively new to the objC language, that's why I would be very happy if you could help me. 

The compiler gives me the following build warning (the code compiles and I can run my app just fine, but I'm curious to know which line of code causes this behavior): "Assignment makes pointer from integer without a cast". The error occurs in the line "age = newAge"... I declared age as an int in the .h file.

CODE:

#import "Person.h"

@implementation Person
@synthesize lastName, firstName, age;

-(id)initWithFirstName:(NSString *)fName name:(NSString *)lName age:(int)newAge;
{
if (self = [super init]) {
lastName = lName;
firstName = fName;
age = newAge; // ERROR occurs here!
}
    return self;
}

Any suggestion would be appreciated. Thanks in advance.
-M

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Assignment makes pointer from integer without a cast (From: Marx Bievor <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.