开发者

Core data and @unionOfSets

开发者 https://www.devze.com 2022-12-24 06:05 出处:网络
Im having trouble using the @unionOfSets on my core-data objects. I have a subclass of nsmanagedobject called list. There is a to-many relationship from list to listElements. and each listElement has

Im having trouble using the @unionOfSets on my core-data objects.

I have a subclass of nsmanagedobject called list. There is a to-many relationship from list to listElements. and each listElement has a one-to-one relationship with a file.

NSLog(@"%@", [NSApp valueForKeyPath:@"delegate.mainWindowController.sidebarViewController.arrayController.selection.list.listElement"]);

Prints the set of listElements as expected

2010-03-24 18:11:15.844 Pirouette[7459:80f] Relationship objects for {(
<PRPlaylistElement: 0x10484c0> (entity: PRPlaylistElement; id: 0x10a71b0 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRPlaylistElement/p108> ; data: <fault>),
<PRPlaylistElement: 0x1048a10> (entity: PRPlaylistElement; id: 0x10ac7d0 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRPlaylistElement/p153> ; data: <fault>),
<PRPlaylistElement: 0x1048460> (entity: PRPlaylistElement; id: 0x10acf60 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRPlaylistElement/p157> ; data: <fault>),
<PRPlaylistElement: 0x1047c60> (entity: PRPlaylistElement; id: 0x10a6850 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRPlaylistElement/p105> ; data: <fault>)

However when I try to get the set of file for each of the listElements.

    NSLog(@"%@", [NSApp valueForKeyPath:@"delegate.mainWindowController.sidebarViewController.arrayController.selection.list.listElement.@unionOfSets.file"]);

I get the following error

2010-03-24 18:41:20.075 Pirouette[7616:80f] An uncaught exception was raised
2010-03-24 18:41:20.082 Pirouette[7616:80f] [<NSCFSet 0x1056e90> valueForKeyPath:]: this class does not implement the unionOfSets operation.
2010-03-24 18:41:20.086 Pirouette[7616:80f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[<NSCFSet 0x1056e90> valueForKeyPath:]: this class does not implement the unionOfSets operation.'

Confused because I thought to-many relationships in core-data were NSSets.

also to note

    NSLog(@"%@", [NSApp valueForKeyPath:@"delegate.mainWindowController.sidebarViewController.arrayController.selection.list.listElement.file"]);

gives the following

2010-03-24 18:16:45.843 Pirouette[7505:80f] {(
<PRSong: 0x10a9c10> (entity: PRSong; id: 0x104a8d0 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRSong/p123> ; data: <fault>),
<PRSong: 0x10a00f0> (entity: PRSong; id: 0x1049b20 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRSong/p128> ; data: <fault>),
<PRSong: 0x10ac480> (entity: PRSong; id: 0x10476a0 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87开发者_StackOverflowA91C/PRSong/p145> ; data: <fault>),
<PRSong: 0x1099cd0> (entity: PRSong; id: 0x104a380 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRSong/p120> ; data: <fault>))}

however for some reason I cant bind the contentSet of a nsarraycontroller to it.


You're using @unionOfArrays rather than @unionOfSets. As the error indicates, this is an array operation rather than a set one.

0

精彩评论

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