Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

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

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 :):)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...