传递自我参数:@selector

我想添加一个NSIndexpath作为参数通过

[self action:@selector(showDetailedImage)]; 

是否可以添加一个额外的参数( NSIndexPath )到这个方法?

不,你不能传递参数 ,你只能显示这个select器将会有很多参数。

如果你需要这样做,你可以创build一个属性,并通过showDetailedImage方法访问它。

但是你可以使用这个select器:

 [self performSelector:@selector(showDetailedImageIndex:) withObject:objectOfNSIndex]; 

做一个包装(另一种方法)说-(void)wrapperMethodOforiginalSelectorMethod; 你的now-selector-method-(void)originalSelectorMethod:(id)argument; 并将包装器作为新的select器,并用您的参数进一步调用您的originalSelectorMethod。

你必须添加额外的参数

ShowDetailedImage:(NSIndexPath *)indexPath

可以调用[self action:@selector(showDetailedImage :)];