cocoa - dictionaryWithContentsOfFile and Sandbox -
i've created mac app load xml file user selected folder, , after using app, user saves customized file (.adgf) when try load .adgf file (that plist file) has xml path within 1 record call dictionarywithcontentsoffile return me "nil". think problem sandbox (sometime works sometime not). string path correct. maybe when user load xml file should save within of particular app "document folder"?
edit: i'm trying right bookmark data solution , retraive nsurl doen't work. code i'm using this:
- (nsdata *)bookmarkfromurl:(nsurl *)url { nserror *error = nil; nsdata *bookmark = [url bookmarkdatawithoptions:nsurlbookmarkcreationwithsecurityscope includingresourcevaluesforkeys:null relativetourl:null error:&error]; if (error) { nslog(@"error creating bookmark url (%@): %@", url, error); [nsapp presenterror:error]; } return bookmark; } - (nsurl *)urlfrombookmark:(nsdata *)bookmark { nsurl *url = [nsurl urlbyresolvingbookmarkdata:bookmark options:nsurlbookmarkresolutionwithsecurityscope relativetourl:null bookmarkdataisstale:no error:null]; return url; }
after user stores file should take bookmark data url using -[nsurl bookmarkdatawithoptions: includingresourcevaluesforkeys: relativetourl: error:]
use nsurlbookmarkcreationwithsecurityscope
options.
this nsdata object should stored somewhere (plist?) , when want read file again in later session can create sandbox compliant nsurl bookmark data using +[nsurl urlbyresolvingbookmarkdata:options:relativetourl:bookmarkdataisstale:error:]
Comments
Post a Comment