在NSOrderedSet中生成的异常生成访问器 [英] Exception thrown in NSOrderedSet generated accessors
问题描述
在我的Lion应用程式上,我有这种资料模式:
subitems
code> 已订购。
Xcode 4.1(build 4B110)为我创建了 h
, Item.m
, SubItem.h
和 SubItem .h
。
以下是 Item.h
的内容(自动生成)
#import< Foundation / Foundation.h>
#import< CoreData / CoreData.h>
@class SubItem;
@interface项目: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
:
#importItem.h
#importSubItem.h
@implementation项目
@dynamic名称;
@dynamic subitems;
@end
正如你所看到的, Item
提供了一个名为 addSubitemsObject:
的方法。不幸的是,当试图以这种方式使用它:
Item * item = [NSEntityDescription insertNewObjectForEntityForName:@IteminManagedObjectContext:self .managedObjectContext];
item.name = @FirstItem;
SubItem * subItem = [NSEntityDescription insertNewObjectForEntityForName:@SubIteminManagedObjectContext:self.managedObjectContext];
[item addSubitemsObject:subItem];
出现此错误:
2011-09-12 10:28:45.236测试[2002:707] *** - [NSSet intersectsSet:]:set参数不是NSSet
您能帮我吗?
更新: >
从我的错误报告,今天(2016年8月1日)只有1787天后,苹果给我写了这个:请验证这个问题与最新的iOS 10测试版本和更新您的错误报告在bugreport.apple.com与您的结果。。让我们希望这是正确的时间:)
解决方案我将您的设置与您的数据模型和我自己的名称。我在两种情况下都有相同的错误。
看起来像是Apple自动生成的代码中的一个错误。
On my Lion app, I have this data model:
The relationship
subitems
insideItem
is ordered.Xcode 4.1 (build 4B110) has created for me the file
Item.h
,Item.m
,SubItem.h
andSubItem.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
And here is the content (autogenerated) of
Item.m
:#import "Item.h" #import "SubItem.h" @implementation Item @dynamic name; @dynamic subitems; @end
As you can see, the class
Item
offers a method calledaddSubitemsObject:
. 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];
this error appear:
2011-09-12 10:28:45.236 Test[2002:707] *** -[NSSet intersectsSet:]: set argument is not an NSSet
Can you help me?
Update:
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.
Looks like a bug in Apple's autogenerated code.
这篇关于在NSOrderedSet中生成的异常生成访问器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!