Objective c 在mac app中将数据导出为csv格式文件

Objective c 在mac app中将数据导出为csv格式文件,objective-c,macos,csv,nssavepanel,Objective C,Macos,Csv,Nssavepanel,我是mac应用程序开发新手 我在nstableview中有一组数据,需要以.cs格式编程保存这些数据 -(IBAction)exportInvoice:(id)sender { AppDelegate *appDelegate = [NSApp delegate]; NSString *tempStr = [NSString stringWithFormat:@"%@", [OrderModel getInitialOrderBITToDisplay:[appDelegate

我是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];

    }
}

有人能帮我解决这个问题吗?

你应该看看CHCSVParser: 希望有帮助