简体   繁体   中英

Passing parameters in self action:@selector

I am trying to add a NSIndexpath as parameter to a method through

[self action:@selector(showDetailedImage)];

Is it possible to add an extra parameter( NSIndexPath ) to this method?

No, you can not pass arguments , you can only show that this selector will take that many numbers of arguments.

If you need to do this, you can create a property and access it from the method showDetailedImage .

However you can use this selector:

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

Make a wrapper(another method) say -(void)wrapperMethodOforiginalSelectorMethod; of your now-selector-method say -(void)originalSelectorMethod:(id)argument; and make the wrapper as your new selector which further calls your originalSelectorMethod with your argument.

You have to add extra parameter to

ShowDetailedImage:(NSIndexPath *)indexPath

can call [self action:@selector(showDetailedImage:)];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM