ios - How do I obtain results of FBRequest requestForMyFriends as a JSON formatted file? -


i'm using objective-c , developing iphone.

i'm sending request friends of logged in user , writing data file disk so:

[[fbrequest requestformyfriends] startwithcompletionhandler:^(fbrequestconnection *connection,                                                                        nsdictionary *results,                                                                        nserror *error) { if(!error){  nsdictionary* friends = results;  nslog(@"found %i friends", friends.count);  nsarray* paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docdir = [paths objectatindex:0]; nsstring* filename = [docdir stringbyappendingpathcomponent:@"userinfo.dat"];  if ([friends writetofile:filename atomically:yes]) {     nslog(@"wrote friends file disk!");     sendfbevent(fb_event_details_friends, [filename utf8string]); } else{     nslog(@"couldn't write friends details disk!"); } 

this works, file retrieved , written disk xml file. in pervious version able save file in json format, have since lost revision , can't remember how achieved it.

i'd appreciate if tell me how possible save file in form of json formatted file? i've done before simple method isn't different current method i'll damned if can remember how.

gah, awfully sorry searching facebook related results when answer native objective c:

objective-c / ios: converting array of objects json string

turns out can use

nsdata* jsondata = [nsjsonserialization datawithjsonobject:contactstobesynced options:nsjsonwritingprettyprinted error:&error]; 

to convert array pulled request json. sorry that, hope useful in future @ least!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -