Plist File Operations

Source: Internet
Author: User

Take out the plist File Processing Section used in the project directly:

// Write data such as data-(void) writeToSendedList :( NSString *) message {// NSArray * storeFilePath = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) in the sandbox ); NSString * doucumentsDirectiory = [storeFilePath objectAtIndex: 0. plist "]; if ([[NSFileManager defaultManager] fileExistsAtPath: [doucumentsdireory ory stringByAppendingPathComponent: @" MessageList. plist "] = NO) {// ================================ write plist initialization data ==== ============================== NSMutableDictionary * messageList = [[NSMutableDictionary alloc] init]; NSMutableDictionary * sendedList = [[NSMutableDictionary alloc] init]; NSMutableArray * hztest01Sended = [[NSMutableArray alloc] Destination: @ "123", @ "12222", @ "fox ", nil]; [sendedList setObject: hztest01Sended forKey: @ "hztest01"]; optional * draftsList = [[using alloc] init]; NSMutableArray * hztest01Drafts = [[NSMutableArray alloc] failed: @ "123", @ "12222", @ "fox", nil]; [draftsList setObject: hztest01Drafts forKey: @ "hztest01"]; [messageList setObject: sendedList forKey: @ "DraftsList"]; [messageList writeToFile: plistPath atomically: YES];} // non-sandbox directory // NSString * plistPath = [[NSBundle mainBundle] pathForResource: @ "SendedList" ofType: @ "plist"]; optional * dictionary = [[NSMutableDictionary alloc] identifier: plistPath]; optional * mydictionary = [[NSMutableDictionary alloc] initWithDictionary: [dictionary objectForKey: @ "SendedList"]; NSMutableArray * mysendedList = [[NSMutableArray alloc] initWithArray: [mydictionary objectForKey: @ "hztest01"]; NSLog (@ "hztest01 sending box: % @", mysendedList); [mysendedList addObject: message]; [mydictionary removeObjectForKey: @ "hztest01"]; [mydictionary setObject: mysendedlforkey: @ "hztest01"]; [dictionary setObject: mydictionary forKey: @ "SendedList"]; [dictionary writeToFile: plistPath atomically: YES]; [mysendedList release]; [mydictionary release]; [dictionary release];}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.