Reputation: 36060
I have to create an educational app where it is basically like a powerpoint presentation with some basic interaction in each slide (answering true or false questions etc...). The app is basically done and I am required to track the progress made by each user. If a user has already completed a slide an image needs to appear somewhere to let him know that the slide is completed.
I know the basics of objective-c therefore it will be nice if I can track this changes by adding a .txt file to the bundle. so the way I think it would be the easiest is to add one .txt file for every user (total of 10 users therefore I need to create 10 .txt files) and once the user completes a slide, add the name of that slide to the .txt file. That way if the user closes the app the next time he opens the app he will still be able to see which slides he completed. Moreover maybe I should create Property List instead of a .txt file.
So in short I want to be able to write and read from .txt or Property List files because I have a deadline for this project and I am not sure if I'll have enough time to learn sqlite.
Upvotes: 0
Views: 430
Reputation: 5999
Use NSUserDefaults. It's a dictionary that can store other serializable objects like NSArrays, NSDictionarys (ies?), NSStrings, etc. You won't have to futz with writing files, either. It's easy.
Also, FYI, files that you include in the bundle can't be edited by the app at runtime. You only have access to the app's documents directory, which is initially empty. If you need a template file, you can include one in the bundle and copy it to the docs directory to make an editable version. Or, you can just write the file to the docs directory from whatever source data you have.
Anyway, you should be able to do what you need to do using NSUserDefaults.
Upvotes: 1
Reputation: 2201
Create your plist from xcode and name it something unique like "completedSlide.plist"
Read the plist to an NSMutableDictionary:
NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@"completedSlide.plist"];
Make changes to the dictionary
[settings setValue:YES forKey:@"SlideOne"];
Save the dictionary to the plist once done
[settings writeToFile:@"completedSlide.plist" automically:YES];
Upvotes: 2