• 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: Booleans
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Booleans


  • Subject: Re: Booleans
  • From: Gregory Weston <email@hidden>
  • Date: Thu, 28 May 2009 07:07:23 -0400

John Ku wrote:

I am trying to set an object's boolean, everything works but I get a warning
of 'pointer from integer without a cast'.
*// ---- Here is the Main Class:*
[theObject setActivated: YES];


*// ---- Here is the Object Class:*
@property(readwrite, assign) BOOL *activated;
@synthesize activated;

- (void) setActivated: (BOOL *) boolean {
 activated = boolean;
}


The weird thing is that if i setActivated: NO, it would not give any warning
or error. Only When I setActivated: YES i get this:
"warning: passing argument 1 of 'setActivated:' makes pointer from integer
without a cast"


Anyone know what's wrong?

Yes. You're trying to make a pointer from an integer without a cast. Specifically, the pointer is the BOOL* argument to setActivated and the integer is 1, or -1 or whatever YES is defined is. NO is defined to be zero, which by the language definition can be assigned to a pointer without a problem. It's just another name for NULL.


Most likely you don't want 'activated' and the argument to setActivated: to be pointers.

_______________________________________________

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


  • Prev by Date: How to make our application as default for particular type of file.
  • Next by Date: Re: Traversing an NSXML subtree
  • Previous by thread: Re: Booleans
  • Next by thread: Laying out superscripted text
  • Index(es):
    • Date
    • Thread