Re: BOOL parameter passed as nil object
Re: BOOL parameter passed as nil object
- Subject: Re: BOOL parameter passed as nil object
- From: Ryan Dignard <email@hidden>
- Date: Mon, 18 Apr 2016 19:02:10 -0700
To answer your second question consider BOOL b = (BOOL)someObj; if someObj
happens to equal something like 0x12345600 the value of b will be NO
because casting from a pointer to a char will return the least significant
byte.
For your first question I don't know exactly but it doesn't look safe; I
think it works if the sizeof a pointer happens to equal the sizeof an int
but I've never done this so I wouldn't know for sure.
On Mon, 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?
>
> 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?
>
> -Carl
>
>
> _______________________________________________
>
> 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