objective c - stringWithContentsOfFile:usedEncoding:error: does not work -
i'm trying import csv created filemaker , copied onto device using itunes filesharing. i'm stuck on should straightforward step. can't see i'm going wrong. tried alternative method , setting utf8 encoding. tried exporting filemaker xml utf8, , tried deleting app phone , rerunning. doesn't seem read encoding if specify it. following code gives me console output.
file exists import (null) error domain=nscocoaerrordomain code=264 "the operation couldn’t 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"); }
}
from header:
nsfilereadunknownstringencodingerror = 264, // read error (string encoding of file contents not determined)
try telling foundation encoding is, know encoding is.
importstring = [nsstring stringwithcontentsoffile: blah encoding: nsutf8stringencoding error: &error];
Comments
Post a Comment