当我从一个确实实现了我试图调用的方法的对象中调用 performSelector:withObject: 时,我得到了一个 EXC_BAD_ACCESS 异常。这是我的代码
SEL newSelector = NSSelectorFromString(@"mySelector:withCustomObject:");
[self performSelector:newSelector withObject:myCustomObject];
这会导致崩溃。但是,当我这样做时
[self performSelector:@selector(mySelector:withCustomObject:) withObject:myCustomObject];
有用。
关于为什么会发生这种情况的任何想法?PS:没有一个参数是零。
更多代码:
// My code to call this method
SEL newSelector = NSSelectorFromString(@"mySelector:withCustomObject:");
[self performSelector:newSelector withObject:self withObject:myCustomObject];
// this code is NOT called.
- (void) mySelector:(jObject *)sender withCustomObject:(jEvent *)customObject
{
NSDictionary *handlerData = [aProperty objectAtIndex:[event positionInMethodStack]];
NSString *newTitle = [handlerData objectForKey:@"newTitle"];
}