我在一篇文章中看到 -(id)arrayByPerformingSelector
接口(interface)中的声明应该可以,但是当我尝试它时,这个声明被视为单独的方法,并且出现了不完整的实现问题......抱歉,这是相当我问的是一个愚蠢的疑问,但我是 iOS 的新手,无法找出这有什么问题..
self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[viewControllers arrayByPerformingSelector:@selector(title)]];
self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
而且当我运行项目时,线程在 SIGABRT 和控制台窗口中停止
"TableView[866:fe03] -[__NSArrayI arrayByPerformingSelector:]: unrecognized selector sent to instance 0x6e65620
2012-03-07 12:31:16.074 TableView[866:fe03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI arrayByPerformingSelector:]: unrecognized selector sent to instance 0x6e65620'"
如果我必须在声明中使用选择器,请告诉我如何...。谢谢大家:):)
最佳答案
我检查了 iOS SDK,但找不到具有该名称的方法。考虑到它会使应用程序崩溃...没有使用该名称的方法。
如果您收到相同类型的警告并且您的应用运行正常,我的回答是 here将是相关的
我不知道您是否开始处理这个 SO 问题:Implementing my own navigation controller? ,但那里接受的答案引用了一个博客。
研究它,你需要:
• 从here 下载NSArray+PerformSelector.h 和NSArray+PerformSelector.m
• 将它们添加到您的 xcode 项目
• 将#import "NSArray+PerformSelector.h"
添加到您遇到崩溃的.m 文件中。
关于ios - 如何解决问题 : "' Instance method '-arrayByPerformingSelector:' not found (return type defaults to 'id' )",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9597136/