Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Rajeev Sharma
1,597 PointsI am getting this error after sorting an MutableArray
NSArrayI sortUsingDescriptors:]: unrecognized selector sent to instance. Please help!
Code:
NSSortDescriptor *sorter = [[NSSortDescriptor alloc] initWithKey:@"tag" ascending:NO];
[self.buttons sortUsingDescriptors:[NSArray arrayWithObject:sorter]]; //Crash happens here
5 Answers
Ben Jakuben
Treehouse TeacherWhat is self.buttons referring to? Is it in fact mutable? It sounds like the sortUsingDescriptors message isn't recognized by whatever self.buttons is.
Rajeev Sharma
1,597 PointsThanks Ben. Really appreciate that. Here is the property of Buttons
@property (nonatomic, strong) IBOutletCollection(className) NSMutableArray *buttons;
Ben Jakuben
Treehouse TeacherOkay, good. Can you paste more code? Maybe your whole .m file? Is buttons being set in viewDidLoad?
When you paste, surround your code with three backticks and "objective-c" on the line before it and three backticks on the line below it, like this:
```objective-c
NSString *test = @"this is a test";
```
NSString *test = @"this is a test";
Rajeev Sharma
1,597 PointsIt was an IBOutletCollection issue. Thanks already :)
Ben Jakuben
Treehouse TeacherCool - glad you got it working!