Does anybody know how to create a plist file per item in an array, so for example I have an add button which lets me add an item, how can I create a plist per item added and how can I then retrieve it back to view the data?
I would include a PLIST in your app bundle and copy it (with a different name each time) to the documents directory as needed. Now that you have a working PLIST, it's as simple as reading your PLIST into a NSMutableDictionary or NSMutableArray, editing it, and writing the results back to the PLIST.
Related
When an iPhone program has something like a paragraph or a set of instructions that need to be displayed on screen--basically anything that is longer than two sentences, where does it go?
Should it be stored as an NSLocalizedString (is this stored in the info.plist? I tried searching documentation--I'm a beginner and don't quite understand where that goes)?
Should it simply be hard-coded into the UITextView or UILabel that contains it?
Should it be defined as a constant then referenced in the UITextView/UILabel?
Should it be placed in a .txt file then referenced? (http://stackoverflow.com/questions/2506594/where-to-put-text-files-for-iphone-uitextview)
If you are thinking about localizing the text at all, I'd put it into a strings file:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html
You could also put it into a plist and read the plist file at runtime from the bundle. Generally try to keep the info.plist clean.
I would put such items in a plist file ad read it in.
I am using TTLauncherView and adding items to it dynamically.
My items are added but once I close the application they are not saved.
I am using a plist to save the items.
In my viewDidLoad, I am using this line _launcherView.pages = [NSArray arrayWithObjects:array, nil];
to load items on TTLauncherView from plist. But this line is throwing exception.
I would really appreciate if anybody can throw some light on it. May be if someone can share the code of how to save added items and their changed positions, if they already have succeeded in doind it.
Any help would be appreciated!
I also looked to this links, but no luck!
dynamically add Items to TTLauncher
This is an old post, so I won't spend too much time here, but if you are already loading your plist successfully, you have (at least) two options: 1) re-save the plist in your documents directory, (making sure to load it from there if it exists), or 2) store your plist data in NSUserDefaults when it has been changed (again, checking NSUserDefaults before loading the original plist).
Hope you figured this all out long ago.
I have a directory structure of directories and files that I want to render as a tableview in an iphone app. I'd rather have this generated dynamically rather than have to maintain a XML PLIST or whatever. i.e. replicate the Explorer functionality in windows where a user can traverse the structure and then select bundled image files for viewing.
Is there any way to do this? Any advice would be appreicated.
What specifically are you having trouble with?
You use NSFileManager to access directory (listings) and files.
You use UITableView to display tables.
Your view controller should use NSFileManager to parse a given directory and display the results in a UITableView.
for my application i am able to read the description of a place selected from the table row and display it in the uitextview. but what i needed to do next is able to save content edited by user in the uitextview to plist. need some guide because i had been searching for it but in vain..thanks
You don't need to use a plist to store a string, you can use -[NSString writeToFile:atomically:encoding:error:] method, and just create a single file.
If you're dead set on creating a plist, you can use the NSPropertyListSerialization class to read and write plists.
i want to modify entries in custom plist file programmatically.
can anybosy suggest me a way to do that? i have tried modifying values of keys but file is not getting saved..
You don't provide much information as to what you've tried, but I assume from the tag that this is on the iPhone. In addition to Pat's suggestion, make sure that the plist you are trying to edit is not within your app bundle, but located within an editable location like Documents or Library within your sandbox.
I would look at the NSDictionary method:
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
I'm sure there's a similar method for NSArray.