开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜