Re: Arg, lmao question - (int)getters/setters.
Re: Arg, lmao question - (int)getters/setters.
- Subject: Re: Arg, lmao question - (int)getters/setters.
- From: Graham Cox <email@hidden>
- Date: Tue, 23 Dec 2008 22:51:31 +1100
On 23 Dec 2008, at 6:14 pm, aaron smith wrote:
Sorry for the total newb here. What's the right way to create
getters/setters for int's? Without the compiler warning about them?
I've been trying:
-(void)setSomeInt:(int)theInt
{
someInt=theInt;
}
-(int)someInt
{
return someInt;
}
Then calling it..
[myObj setSomeInt:1];
Usually I get two warnings:
"warning: assignment makes pointer from integer without cast"
"warning: return makes integer from pointer without cast"
Your methods are correct. But did you also prototype them in the
header? The code (.m file) for <myObj> needs to import this header so
that it knows that the methods in question accept and return an int,
otherwise, the compiler assumes object (id) types and hence spits out
the warning.
hth, Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden