Last active
August 29, 2015 14:24
-
-
Save jasonmcdermott/71f4225d1e40caf86edb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // assumes object class called SENQuestionnaire | |
| - (void)writeDictionaryToDisk:(SENQuestionnaire *)q | |
| { | |
| NSDictionary *dataDictionary = | |
| @{ | |
| @"stringA" : @"string A", | |
| @"stringB" : @"string B", | |
| @"stringC" : @"string C", | |
| }; | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; | |
| NSString *doc = [basePath stringByAppendingString:@"/"]; | |
| NSString *file = [doc stringByAppendingString:q.uniqueID]; | |
| NSString *filePath = [file stringByAppendingString:@".plist"]; | |
| // plistDict is a NSDictionary | |
| NSString *error; | |
| NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:dataDictionary | |
| format:NSPropertyListXMLFormat_v1_0 | |
| errorDescription:&error]; | |
| if(plistData) { | |
| [plistData writeToFile:filePath atomically:YES]; | |
| } else { | |
| NSLog(@"%@",error); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment