how to resolve the issue: “'Instance method &#

2019-01-20 16:51发布

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条回答
2楼-- · 2019-01-20 17:31

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.

查看更多
登录 后发表回答