• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Arg, lmao question - (int)getters/setters.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arg, lmao question - (int)getters/setters.


  • Subject: Re: Arg, lmao question - (int)getters/setters.
  • From: Roland King <email@hidden>
  • Date: Tue, 23 Dec 2008 15:19:43 +0800

it looks as if you your class variable someInt declared as (int*), why? If you want an int, someInt should be declared as an int.

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"

From those two warnings, I was thinking these updates do the trick:

-(void)setSomeInt:(int)theInt { someInt=(int *)theInt; }

-(int)someInt
{
   return (int)someInt;
}

Calling it:
[myObj setSomeInt:(int *)1];

Is this the correct way?
Thanks all..
_______________________________________________

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



_______________________________________________

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


  • Follow-Ups:
    • Re: Arg, lmao question - (int)getters/setters.
      • From: Robert Marini <email@hidden>
References: 
 >Arg, lmao question - (int)getters/setters. (From: "aaron smith" <email@hidden>)

  • Prev by Date: Arg, lmao question - (int)getters/setters.
  • Next by Date: Re: Setting Caps Lock state from the application
  • Previous by thread: Arg, lmao question - (int)getters/setters.
  • Next by thread: Re: Arg, lmao question - (int)getters/setters.
  • Index(es):
    • Date
    • Thread