我是 Mac 应用程序开发的新手。
我在 nstableview 中有一组数据,我需要以编程方式将这些数据保存为 .cs 格式。
-(IBAction)exportInvoice:(id)sender
{
AppDelegate *appDelegate = [NSApp delegate];
NSString *tempStr = [NSString stringWithFormat:@"%@", [OrderModel getInitialOrderBITToDisplay:[appDelegate getDBPath]]];
NSArray* commaSeparatedObjects = [tempStr componentsSeparatedByString:@","];
//NSString *commaSeparatedObjects = [tempStr componentsJoinedByString:@","];
NSLog(@"%@",commaSeparatedObjects);
NSSavePanel *pdfSavingDialog = [NSSavePanel savePanel];
[pdfSavingDialog setRequiredFileType:@"csv"];
if ( [pdfSavingDialog runModalForDirectory:nil file:nil] == NSOKButton ) {
// NSData *dataForPDF = [self exportPdfData];
NSData *dataForPDF = [NSKeyedArchiver archivedDataWithRootObject:commaSeparatedObjects];
NSLog(@"%@",dataForPDF);
[dataForPDF writeToFile:[pdfSavingDialog filename] atomically:NO];
}
}
谁能帮我解决问题?