(void)insertObj
{
// Put some data in the table if there's not enough
NSArray allColors = [Color allInstances];
NSUInteger numPeople = [Person numberOfInstances];
NSTimeInterval date1 = [NSDate.date timeIntervalSince1970];
NSLog(@"date1:%f",date1);
while (numPeople < 1000) {
Person p = [Person new];
[p save:^{
p.name = [@"xiaohong" stringByAppendingString:[@(numPeople) stringValue]];//[RandomThings randomName];
NSInteger num = numPeople;
if (num >= allColors.count) {
num = arc4random() % allColors.count;
}
Color *color = allColors[num];
p.color = color;
}];
(void)insertObj { // Put some data in the table if there's not enough NSArray allColors = [Color allInstances]; NSUInteger numPeople = [Person numberOfInstances]; NSTimeInterval date1 = [NSDate.date timeIntervalSince1970]; NSLog(@"date1:%f",date1); while (numPeople < 1000) { Person p = [Person new]; [p save:^{ p.name = [@"xiaohong" stringByAppendingString:[@(numPeople) stringValue]];//[RandomThings randomName]; NSInteger num = numPeople; if (num >= allColors.count) { num = arc4random() % allColors.count; } Color *color = allColors[num]; p.color = color; }];
} NSLog(@"date2:%f",[NSDate.date timeIntervalSince1970]); }
the output result : 2017-07-10 15:13:43.624140 FCModelTest[14829:3666710] date1:1499670823.624041 2017-07-10 15:13:58.527835 FCModelTest[14829:3666710] date2:1499670838.527774
so it takes about 15s when I save 1000 datas, Is there anything wrong ?thanks for help~