gpt4 book ai didi

cocoa - 核心数据和@unionOfSets

转载 作者:行者123 更新时间:2023-12-03 17:45:00 26 4
gpt4 key购买 nike

我在核心数据对象上使用 @unionOfSets 时遇到问题。

我有一个名为 list 的 nsmanagementobject 子类。 list 到 listElements 之间存在一对多关系。并且每个listElement与文件具有一对一的关系。

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

按预期打印 listElements 集

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

但是,当我尝试获取每个 listElements 的文件集时。

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

我收到以下错误

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.'

很困惑,因为我认为核心数据中的 to-many 关系是 NSSet。

还要注意

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

给出以下内容

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-47764B87A91C/PRSong/p145> ; data: <fault>),
<PRSong: 0x1099cd0> (entity: PRSong; id: 0x104a380 <x-coredata://1EE9CEAD-E006-4487-8AA7-47764B87A91C/PRSong/p120> ; data: <fault>))}

但是由于某种原因我无法将 nsarraycontroller 的 contentSet 绑定(bind)到它。

最佳答案

您使用的是@unionOfArrays而不是@unionOfSets。正如错误所示,这是一个数组操作而不是集合操作。

关于cocoa - 核心数据和@unionOfSets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2512601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com