-1
我正在尝试将数组保存到核心数据。我一直在评论以下主题:Storing custom objects in an NSMutableArray in NSUserDefaults(特别是Stefan的回答)。我的代码如下:将数组保存到核心数据
for (TempWorkout *newTempWorkout in items)
{
NSString *strCounterInt = [NSString stringWithFormat:@"%d", counterInt];
newTempWorkout.temp_time = strCounterInt;
newTempWorkout.temp_route = route.text;
newTempWorkout.temp_activity = activity.text;
newTempWorkout.temp_intensity = intensity.text;
NSString *strTotalDistance = [NSString stringWithFormat:@"%.3f", totalDistance];
newTempWorkout.temp_distance = strTotalDistance;
newTempWorkout.temp_mapID = mapID;
[[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:startTimeArray] forKey:@"temp_start_time"];
[self.tempWorkoutArray addObject:newTempWorkout];
}
上面的代码工作,但是当我看着我的表(通过在浏览器SQLITE经理),我没有看到钥匙“temp_start_time”的任何值。
问候, 斯蒂芬
感谢Nick,我放弃了这种方法,只是将数组作为字符串存储在Core Data中。 – Stephen 2010-09-30 15:43:54