我是 iOS 新手。我在 .m 文件中定义了以下方法,需要将其名称添加到 .h 文件中。
-(Boolean) addBookFromArrayOne:(Book*)bookOne bookTwo:(Book*)bookTwo mergeByThisField:(NSString*)field sortDescending:(Boolean)
此帖Method Syntax in Objective C对学习 Objective C 方法语法非常有帮助。答案
in Objective-C, the name of a method is composed of all of the portions of the declaration that are not arguments and types. This method's name would therefore be: pickerView:numberOfRowsInComponent:
特别有帮助。
但它没有显示如何泛化到多个参数。
我猜测了头文件中的语法,但显然是错误的:
@property Boolean addBookFromArrayOne:bookTwo:mergeByThisField:sortDescending;
谁能告诉我如何在头文件中定义这个方法名?
最佳答案
只需将方法声明从实现复制到 header
-(Boolean) addBookFromArrayOne:(Book*)bookOne bookTwo:(Book*)bookTwo mergeByThisField:(NSString*)field sortDescending:(Boolean)desc;
关于objective-c - 如何在 .h 文件中写入具有多个参数的方法的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13113928/