选择器 - 我总是需要传递一个对象吗?

时间:2013-07-07 09:18:01

标签: ios objective-c selector

我对选择器的使用相对较新,所以我正在玩它,我不想传递选择器任何对象,相反它的目的只是告诉类更新自己。我将它们声明为任何其他方法,但只有当它需要一个参数才能工作时,为什么会这样?

//This works    
- (void) updateButtonImageState:(id)object;
// Calling it
[cell performSelector:@selector(updateButtonImageState:) withObject:@"object"];

-

//This crashes  
//Declaring the selector
- (void) updateButtonImageState;
// Calling it
[cell performSelector:@selector(updateButtonImageState:)];

1 个答案:

答案 0 :(得分:3)

你不应该在选择器名称的末尾使用冒号:

[cell performSelector:@selector(updateButtonImageState)];