ios - 如何解决问题 : "' Instance method '-arrayByPerformingSelector:' not found (return type defaults to 'id' )"

标签 ios uiviewcontroller nsarray xcode4.2

我在一篇文章中看到 -(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.hNSArray+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/

相关文章:

ios - 比较两个 NSArray 并检测变化的最佳方法是什么

ios - SpriteKit 场景图像在模拟器上显示为红十字

ios - 是什么让用户可以被 CKDiscoverAllUserIdentitiesOperation 发现?

ios - Swift:将数据从 UITableView 发送到 UIViewController

ios - 仅在一个 UIViewController 上强制横向 View

View 上带有 slider 和 2 个按钮的 iOS 应用程序

iphone - 如何创建一个 NSDictionarys 数组

ios - 尝试获取当前位置时快速用户的位置问题

ios - 如何从我的手机库中选择 PDF 文件作为 iOS 应用程序的附件?

iphone - 将 NSArrays 转换为 C 样式( double )数组的最快例程是什么?