1 / 6

Chapter 5 – Step 2 Dynamic data

Chapter 5 – Step 2 Dynamic data. Now when we add a tag, we will write it to a file And when we start the app, we will read from that file. Controller.h. We will now make use of the filePath instance variable In the init method, we will try to read from the file storing the tags

aaralyn
Télécharger la présentation

Chapter 5 – Step 2 Dynamic data

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 – Step 2 Dynamic data • Now when we add a tag, we will write it to a file • And when we start the app, we will read from that file

  2. Controller.h • We will now make use of the filePath instance variable • In the init method, we will try to read from the file storing the tags • If there is data, we will initialize tags with the data

  3. Init method • Go through same procedure as before to read from a file • Use name tagsIndex.plist for the file • If we find the file, then we initialize tags with its contents tags = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];

  4. viewDidLoad • Inside viewDidLoad (called when view has loaded) /* loop through all the tags, add a button for each of them */ for( NSString *title in tags ) [self addNewButtonWithTitle:title];

  5. addTag method After we add a tag to tags, we need to overwrite the file with tags We can write an entire dictionary at a time [tags writeToFile: filePath atomically:NO];

  6. Run the app Run the app and save buttons Close the app, run again • Saved buttons should come up

More Related