I am trying to import the csv created by the file wizard and copied to my device using iTunes filesharing. I was stuck on what should be a simple step. I just donβt see where I am wrong. I tried an alternative method and set the encoding to UTF8. Also tried to export from filemaker as xml UTF8, and also tried to remove the application from the phone and try again. It does not seem to read the encoding, even if I specify it. The following code gives me this console output.
File exists Import (null) Domain error = NSCocoaErrorDomain Code = 264 "Operation could not be completed. (Cocoa error 264.)"
-(void)importDatabase { NSString *importString; NSError *error; NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; if ([[NSFileManager defaultManager] fileExistsAtPath:[documentsDirectoryPath stringByAppendingString:@"/iPhone.csv"]]) { NSLog(@" File exists"); NSStringEncoding encoding; importString = [NSString stringWithContentsOfFile:[documentsDirectoryPath stringByAppendingString:@"/iPhone.csv"] usedEncoding:&encoding error:&error]; NSLog(@"Import %@ %@ ",importString, error); } else { NSLog(@" File doesn't exist"); }
}
codeDoctor
source share