我想将10个元素添加到Core Data存储中。如何添加10个元素到核心数据?
问题是只添加了最后一个元素。
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Test" inManagedObjectContext:[self managedObjectContext]];
Test *test = [[[Test alloc] initWithEntity:entity insertIntoManagedObjectContext:[self managedObjectContext]] autorelease];
for (int i =0; i<10; i++)
{
test.text = @"Text";
test.index = [NSNumber numberWithInt:i];
[self saveContext];
}
我犯了同样的错误 – ToddB