initWithArray doesn't work with NSArray property
In viewDidLoad, I ha开发者_JAVA百科ve:
NSArray *selectedPeople = [[selectedObject people] allObjects];
NSArray *peeps = [[NSArray alloc] initWithArray:selectedPeople];
This works just fine, but when I use an NSArray that was declared in my properties it doesn't:
NSArray *selectedPeople = [[selectedObject people] allObjects];
people = [[NSArray alloc] initWithArray:selectedPeople];
The program crashes and says that:
[People isEqualToString:]: unrecognized selector sent to instance 0x6031910
I'm using CoreData and selectedPeople holds People objects. I'm not sure what I'm missing here.
I'm pretty sure Core Data setters for a collection of objects take a set and not an array.
You could try the following:
self.people = [[NSSet setWithArray:selectedPeople];
Is people one of your properties? Did you mean to do:
self.people = [[NSArray ...
instead?
精彩评论