ios - networking works on simulator does not work on iPhone device -
ios - networking works on simulator does not work on iPhone device -
this code works flawlessly on simulator, writes out file.
on iphone however, not write file out.
dlog(@""); timestart = [nsdate date]; nsurl *url = [nsurl urlwithstring:sat_url]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; afhttprequestoperation *operation = [[afhttprequestoperation alloc] initwithrequest:request]; nsstring *path = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:file_name]; operation.outputstream = [nsoutputstream outputstreamtofileatpath:path append:no]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { dlog(@"updated words to: %@",path); //dlog(@"response: %@",responseobject); [self processwords]; } failure:^(afhttprequestoperation *operation, nserror *error) { // deal failure }]; [operation start];
rawwords , lines null on device:
nsstring *path = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:file_name]; nsstring *rawwords = [nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:nil]; nsarray *lines = [rawwords componentsseparatedbystring:@"\n"];
this uses afnetworking lib , i've tried fetching file different hosters.
what doing wrong?
you cannot write bundle (definitely not on device, maybe possible in simulator). can write few predefined directories though (cache, documents). check out next post on stackoverflow: nssearchpathfordirectoriesindomains explanation confused
iphone ios afnetworking simulator
Comments
Post a Comment