2012-11-20 21 views
1

我是新開發的mac應用程序開發人員。將數據導出到mac應用程序中的csv格式文件

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

    } 
} 

任何人都可以幫助我排序的問題?

回答

相關問題