iphone - Question concerning File Handling -


i got following problem : trying create file following code :

nsstring *homedirectory = nshomedirectory(); nsstring *documentdirectory = [homedirectory stringbyappendingpathcomponent:@"documents"]; nsstring *filepath = [documentdirectory stringbyappendingpathcomponent:@"test.txt"];  nsfilehandle *savedfile = nil; savedfile = [[nsfilehandle filehandleforwritingatpath:filepath]retain];  nsstring *data = @"testmessage"; [savedfile writedata:[string datausingencoding:nsutf8stringencoding]]; [savedfile synchronizefile]; [savedfile closefile]; 

my question following. running on mac not give me errors whatsoever. file seems nonexistant or @ least not locateable. need find , access file , have able export mac using mobile ios device

thanks in advance :)

h4wkeye

you need check savedfile not nil (see the docs here).

nsstring *homedirectory = nshomedirectory(); nsstring *documentdirectory = [homedirectory stringbyappendingpathcomponent:@"documents"]; nsstring *filepath = [documentdirectory stringbyappendingpathcomponent:@"test.txt"];  nsfilehandle *savedfile = nil; savedfile = [[nsfilehandle filehandleforwritingatpath:filepath]retain];  if (nil == savedfile) {     nslog(@"could not create saved file @ %@", filepath); }  nsstring *data = @"testmessage"; [savedfile writedata:[string datausingencoding:nsutf8stringencoding]]; [savedfile synchronizefile]; [savedfile closefile]; 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -