问题描述
在我的 Lion 应用上,我有这个数据模型:
On my Lion app, I have this data model:
Item
内的subitems
关系有序.
Xcode 4.1 (build 4B110) 为我创建了文件 Item.h
、Item.m
、SubItem.h
和 SubItem.h
.
Xcode 4.1 (build 4B110) has created for me the file Item.h
, Item.m
, SubItem.h
and SubItem.h
.
这是Item.h
的内容(自动生成):
Here is the content (autogenerated) of Item.h
:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class SubItem;
@interface Item : NSManagedObject {
@private
}
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSOrderedSet *subitems;
@end
@interface Item (CoreDataGeneratedAccessors)
- (void)insertObject:(SubItem *)value inSubitemsAtIndex:(NSUInteger)idx;
- (void)removeObjectFromSubitemsAtIndex:(NSUInteger)idx;
- (void)insertSubitems:(NSArray *)value atIndexes:(NSIndexSet *)indexes;
- (void)removeSubitemsAtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectInSubitemsAtIndex:(NSUInteger)idx withObject:(SubItem *)value;
- (void)replaceSubitemsAtIndexes:(NSIndexSet *)indexes withSubitems:(NSArray *)values;
- (void)addSubitemsObject:(SubItem *)value;
- (void)removeSubitemsObject:(SubItem *)value;
- (void)addSubitems:(NSOrderedSet *)values;
- (void)removeSubitems:(NSOrderedSet *)values;
@end
这是Item.m
的内容(自动生成):
And here is the content (autogenerated) of Item.m
:
#import "Item.h"
#import "SubItem.h"
@implementation Item
@dynamic name;
@dynamic subitems;
@end
如您所见,Item
类提供了一个名为 addSubitemsObject:
的方法.不幸的是,当尝试以这种方式使用它时:
As you can see, the class Item
offers a method called addSubitemsObject:
. Unfortunately, when trying to use it in this way:
Item *item = [NSEntityDescription insertNewObjectForEntityForName:@"Item" inManagedObjectContext:self.managedObjectContext];
item.name = @"FirstItem";
SubItem *subItem = [NSEntityDescription insertNewObjectForEntityForName:@"SubItem" inManagedObjectContext:self.managedObjectContext];
[item addSubitemsObject:subItem];
出现这个错误:
2011-09-12 10:28:45.236 Test[2002:707] *** -[NSSet intersectsSet:]: set argument is not an NSSet
你能帮我吗?
更新:
在我的错误报告仅 1,787 天后,今天(2016 年 8 月 1 日)Apple 写信给我:请使用最新的 iOS 10 测试版验证此问题并在 bugreport.apple.com 上更新您的错误报告与您的结果.".让我们希望这是正确的时间:)
After just 1,787 days from my bug report, today (August 1, 2016) Apple wrote me this: "Please verify this issue with the latest iOS 10 beta build and update your bug report at bugreport.apple.com with your results.". Let's hope this is the right time :)
推荐答案
我使用您的数据模型和我自己的不同名称的数据模型复制了您的设置.在这两种情况下我都遇到了同样的错误.
I reproduced your setup both with your data model and one of my own with different names. I got the same error in both cases.
看起来像是 Apple 自动生成的代码中的错误.
Looks like a bug in Apple's autogenerated code.
这篇关于NSOrderedSet 生成的访问器中抛出的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!