Re: -performSelector: exception... in one build configuration
Re: -performSelector: exception... in one build configuration
- Subject: Re: -performSelector: exception... in one build configuration
- From: Steve Christensen <email@hidden>
- Date: Thu, 03 Nov 2011 09:49:31 -0700
Yes, then -performSelector: executes without generating an exception. One interesting thing I noticed is that there's only a single instance of the literal string for the selector name in the link map, even though I'm seeing two different addresses for the selector for the same method. (And looking at the memory address for a SEL, it looks like it's currently just a null-terminated C string.)
On Nov 2, 2011, at 7:33 PM, Ludovic Nicolle wrote:
> interesting.
>
> at least we know the selectors are not equal.
>
> if you replace storedSelector with supposedSelector, does it then performsSelector as expected ?
>
> Ludo
>
> On 2011-11-02, at 7:16 PM, Steve Christensen wrote:
>
>> On Nov 2, 2011, at 6:24 PM, Ludovic Nicolle wrote:
>>
>>> Hi Steve,
>>>
>>> well, as much as it is quite unlikely that the target object is invalid since you are using [NSUserDefaults standardUserDefaults], Michael's question can be slightly adapted to see if your selector is what you think.
>>>
>>>> I'm always messaging [NSUserDefaults standardUserDefaults]. I have a static array (not NSArray) of C structs, containing various bits of info, including a selector for a particular NSUserDefaults method in my category, so the code looks something like this:
>>>>
>>>> x = [[NSUserDefaults standardUserDefaults] performSelector:someItems[i].selector];
>>>
>>> if you write and execute this code:
>>>
>>> SEL storedSelector = someItems[i].selector;
>>> NSString* storedSelectorString = NSStringFromSelector(storedSelector);
>>>
>>> SEL supposedSelector = @selector(whateverYouThinkShouldBethere);
>>> NSString* supposedSelectorString = NSStringFromSelector(supposedSelector);
>>>
>>> BOOL selectorsEqual = (storedSelector == theSupposedSelector);
>>>
>>> if (selectorsEqual)
>>> NSLog(@"my two selectors are equal with a selector string = %@", storedSelectorString);
>>> else
>>> NSLog(@"my two selectors are different. \n storedSelector string = %@ \n supposedSelector string = %@ ", storedSelectorString, supposedSelectorString);
>>>
>>>
>>> whateverYouThinkShouldBethere should be the supposed selector, of course.
>>>
>>> What is the output?
>>
>>
>> I added one extra check that compares the two NSStringFromSelector() values as well. For the "good" configurations (simulator debug/release + device debug), I get:
>>
>> my two selectors are equal with a selector string = "foo"
>> my two selector names are equal with a selector string = "foo"
>>
>> For the "bad" configuration (device release), I get:
>>
>> my two selectors are different.
>> storedSelector string = "foo"
>> supposedSelector string = "foo"
>> my two selector names are equal with a selector string = "foo"
>>
>> steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden