how to resolve the issue: “'Instance method '-arrayByPerformingSelector:' not found (return type defaults to 'id')”

拥有回忆 提交于 2019-11-27 08:31:14

问题


i saw in one post -(id)arrayByPerformingSelector declaration in interface should do , but when i tried it this declaration was treated as separate method and incomplete implementation issue came... sorry this is quite a silly doubt i am asking but I'm a newbie to iOS and wasn't able to find out whats wrong with this..

self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[viewControllers arrayByPerformingSelector:@selector(title)]];
self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;

and also when i run the project thread stops with SIGABRT and in console window

"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'"

if i have to use selector in declaration please do tell me how.... Thanks all :):)


回答1:


I checked the iOS SDK and couldn't find a method with that name. Considering it is making the app crash... there isn't a method with that name.

If you get that same type of warning and your app works fine, my answer here would be relevant

I don't know if you got started on this SO question: Implementing my own navigation controller?, but the accepted answer there references a blog.

Researching that, you will need to:
• download NSArray+PerformSelector.h and NSArray+PerformSelector.m from here
• add them to your xcode project
• add #import "NSArray+PerformSelector.h" to the .m file you are experiencing your crash in.



来源:https://stackoverflow.com/questions/9597136/how-to-resolve-the-issue-instance-method-arraybyperformingselector-not-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!