且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Objective-C:调用具有多个参数的选择器

更新时间:2023-09-13 14:57:16

您的方法签名是:

- (void) myTest:(NSString *)

withAString恰好是参数(名称具有误导性,它似乎是选择器签名的一部分).

withAString happens to be the parameter (the name is misleading, it looks like it is part of the selector's signature).

如果您以这种方式调用该函数:

If you call the function in this manner:

[self performSelector:@selector(myTest:) withObject:myString];

它将起作用.

但是,正如其他张贴者所建议的那样,您可能需要重命名该方法:

But, as the other posters have suggested, you may want to rename the method:

- (void)myTestWithAString:(NSString*)aString;

然后致电:

[self performSelector:@selector(myTestWithAString:) withObject:myString];