• 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: BOOL parameter passed as nil object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL parameter passed as nil object


  • Subject: Re: BOOL parameter passed as nil object
  • From: Greg Parker <email@hidden>
  • Date: Tue, 19 Apr 2016 10:32:45 -0700

> On Apr 18, 2016, at 6:56 PM, Carl Hoefs <email@hidden> wrote:
>
> Suppose I have an object with a declared method signature:
>  -(void)myMethod:(BOOL)a_bool;
>
> Q1: If I invoke it like this:
>  [self performSelector:@selector(myMethod:) withObject:nil];  // nil obj
> Will argument a_bool end up with a 0 value assigned to it?

Don't do that. The behavior is undefined. It probably happens to work on all current architectures.


> Q2: But if I invoke it like this:
>  [self performSelector:@selector(myMethod:) withObject:someObj];  // valid obj
> Will argument a_bool end up with a 1 value assigned to it?

Don't do that. The behavior is undefined. It will certainly fail on some current architectures at least some of the time.

You should not use -performSelector:withObject: to call methods that use non-object parameters.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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


References: 
 >BOOL parameter passed as nil object (From: Carl Hoefs <email@hidden>)

  • Prev by Date: Re: BOOL parameter passed as nil object
  • Next by Date: Re: Proper way to set up constants when building an iOS framework
  • Previous by thread: Re: BOOL parameter passed as nil object
  • Next by thread: How to make an app launch on login?
  • Index(es):
    • Date
    • Thread