objective c - Retrieving URL from saved plist file -
hi new objective c.
i saving url data in plist file under resource. here code.
nsstring *plistpath =[[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"myfile.plist"]; nsdictionary *plistdict = [[nsuserdefaults standarduserdefaults] dictionaryrepresentation]; if([plistdict writetofile:plistpath atomically:yes]) { nslog(@"success"); } else { nslog(@"error"); }
now want retrieve url saved plist (my file.plist), how can retrieve can use url web view.
e.g:
urlstring.stringvalue = ????
here using urlstring.stringvalue
webview.
[[webview mainframe] loadrequest:[nsurlrequest requestwithurl: [nsurl urlwithstring:urlstring.stringvalue]]];
thanks
first, don't need save nsuserdefaults file yourself. contents saved automatically @ periodic intervals, or can call synchronize
save immediately.
but if want save dictionary plist, use writetofile:atomically:
method have. can load again creating new dictionary contents of plist:
[nsdictionary dictionarywithcontentsoffile:plistpath];
Comments
Post a Comment