Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法添加到已排序集_Ios_Objective C - Fatal编程技术网

Ios 无法添加到已排序集

Ios 无法添加到已排序集,ios,objective-c,Ios,Objective C,我刚刚进入coreData,并尝试使用有序集。我不明白为什么对象没有添加到有序集。我想将该对象添加到self.project.toEntries 以下是截图:[1]: 这是因为无论是什么,self.project,都是nil。您从未将任何对象分配给此属性。谢谢。我误解了属性。学习Swift可能会让你更开心,因为它可以防止你犯这个错误。 - (void)addEntryWithStartDate { Entry *entry = [NSEntityDescription insertNewObje

我刚刚进入coreData,并尝试使用有序集。我不明白为什么对象没有添加到有序集。我想将该对象添加到self.project.toEntries

以下是截图:[1]:


这是因为无论是什么,
self.project
,都是
nil
。您从未将任何对象分配给此属性。

谢谢。我误解了属性。学习Swift可能会让你更开心,因为它可以防止你犯这个错误。
- (void)addEntryWithStartDate
{
Entry *entry = [NSEntityDescription insertNewObjectForEntityForName:newEntry inManagedObjectContext:[TTStack sharedInstance].managedObjectContext];

NSMutableArray *mutableEntries = [[NSMutableArray alloc] initWithArray:[self.project.toEntries array]];
[mutableEntries addObject:entry];
NSOrderedSet *orderdedSet = [NSOrderedSet orderedSetWithArray:mutableEntries];
self.project.toEntries = orderdedSet;

entry.startDate = [[NSDate alloc] init];

[self save];
}