我已經完成了以下操作,將提取的請求放入數組數組中,但現在我不知道需要從chcsvparser調用哪些方法將其寫入csv文件試圖使用chcsvparser將coredata寫入csv
NSArray *objectsForExport = [fetchedResultsController fetchedObjects];
NSArray *exportKeys = [NSArray arrayWithObjects:@"best_checkout", @"darts_thrown", @"high_score", @"score_100", @"score_140", @"score_180",@"three_dart_average",nil];
NSMutableArray *csvObjects = [NSMutableArray arrayWithCapacity:[objectsForExport count]];
for (NSManagedObject *object in objectsForExport) {
NSMutableArray *anObjectArray = [NSMutableArray arrayWithCapacity:[exportKeys count]];
for (NSString *key in exportKeys) {
id value = [object valueForKey:key];
if (!value) {
value = @"";
}
[anObjectArray addObject:[value description]];
}
[csvObjects addObject:anObjectArray];
}
謝謝我已經讀了幾次,但我不明白我需要調用哪些方法。 – lps 2011-04-02 16:47:15
您是否嘗試過:writeToCSVFile:方法? – 2011-04-02 16:51:46
我試過這樣但它字符串似乎是空的:\t [csvObjects writeToCSVFile:exportString atomically:NO]; \t NSLog(@「exportString%@」,exportString); – lps 2011-04-02 17:13:21