Question Write Plist with Loop

Discussion in 'iOS Development' started by NolesFans, Sep 29, 2008.

  1. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    Code:
    if ([elementName isEqualToString:@"event"]) {
    		// save values to an item, then store that item into the array...
    		[item setObject:opp forKey:@"opponent"];
    		[item setObject:date forKey:@"date"];
    		[item setObject:times forKey:@"time"];
    		//XXX: Can It be save to the Schedule.plist file?
    		[stories addObject:[item copy]];
    }
    Is there is write those 3 data into a plist file, I figured it needs a loop for it. Can it be done?
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Code:
    if ([elementName isEqualToString:@"event"]) {
    		// save values to an item, then store that item into the array...
    		[item setObject:opp forKey:@"opponent"];
    		[item setObject:date forKey:@"date"];
    		[item setObject:times forKey:@"time"];
    		[item writeToFile:pathtoYourFile atomically:YES];  //You should try to do atomically whenever possible.  That way your file isn't corrupted in case your app crashes, or whatever when you're writing.
    		[stories addObject:[item copy]];
    }
  3. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    Is that be like

    Root
    - oppontent
    - date
    - time
    in a plist file?

    I am planning to do 3 days update for a plist file too.

    Root
    - stimer string (3 day)
    - Schedule Data Dictionary
    ------- oppontent
    ------- date
    ------- time

Share This Page