Re: NSSelectorFromString crash
Re: NSSelectorFromString crash
- Subject: Re: NSSelectorFromString crash
- From: Chris Kane <email@hidden>
- Date: Tue, 1 May 2001 18:22:14 -0700
On Tuesday, May 1, 2001, at 07:39 AM, Stefan Jung wrote:
Hello,
I was able to crash NSSelectorFromString with a little help from
the following code:
- (SEL)setAccessorFromIdentifier:(NSString *)identifier
{
NSString *string = [@"set" stringByAppendingString:
[[identifier capitalizedString]
stringByAppendingString:@":"]];
return NSSelectorFromString(string);
}
I think if you check 'string' before the call, you'll find it is nil,
just before the crash. nil is not a valid parameter to
NSSelectorFromString(). You can work around this by checking for
string == nil yourself and returning (SEL)0 (as long as whatever code is
calling setAccessorFromIdentifier: can handle that.
Chris Kane
Cocoa Framework, Apple, Inc.