plist

NSBundle, plist and other resources in an Obj-c Static Library

做~自己de王妃 提交于 2019-11-29 20:29:31
I've created a static library in Xcode, which I am able to successfully use in other projects. However, with resources like plists, I find I must include any plists referenced in my library in the main project where the project is used. In my static library project, I have my plist included in the "Copy Bundle Resources" phase of the target. In my code, here is what I am doing: NSBundle *mainBundle = [NSBundle mainBundle]; NSString *filePath = [mainBundle pathForResource:@"MyClassParams" ofType:@"plist"]; NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithContentsOfFile

How to know which line of plist file is incorrect

自古美人都是妖i 提交于 2019-11-29 20:09:09
I generate plist file for my application from file in csv format. Everything seems to be correct but when I try to build application or open plist file in XCode i Get an error informing that: mydata.plist:0: error: reading plist: The data couldn’t be read because it has been corrupted. File contains a lot of data so it might be hard to manually find line which is incorrect. Is it possible to validate file and get information which line is incorrect? Try running the following command in Terminal: plutil <PATH_TO_FILE> It will tell you what the problem is and give you the line number. Open plist

Converting plist to binary plist

时间秒杀一切 提交于 2019-11-29 19:46:15
Apple strongly recommends using the binary plist format when reading large XML-based data sets into iPhone apps. Among their reasoning is the fact that XML parsing is very taxing on the iPhone. However, this requires that files residing on the remote web server be converted first. For frequently-changing content, it is not acceptable to do this manually. If at all possible, I'd like to avoid having a web based app call the command line to perform the conversion (i.e., plutil). Are there publicly available algorithms to perform this conversion? Yes. All the plist code is part of CoreFoundation,

How to save an array to .plist in the App's mainBundle in swift

久未见 提交于 2019-11-29 18:07:47
How I can save array to .plist with array type? I try this, but is not working let path = NSBundle.mainBundle().pathForResource("Setting", ofType: "plist") let arrayWithProperties = NSArray(array: [ NSNumber(integer: nowThemeSelected), NSNumber(integer: imageForBackgroundNumber), NSNumber(integer: imageForButtonNumber), NSNumber(integer: colorOfButton)]) arrayWithProperties.writeToFile(path!, atomically: true) You can't write to the main bundle in iOS, everything inside your Apps bundle is read only. [The App's bundle ] directory contains the app and all of its resources. You cannot write to

iPhone Dev - Edit objects in Array from Plist

只愿长相守 提交于 2019-11-29 17:29:45
I have a Plist in which I have a number of Array's. Within these arrays are different objects that I'm reading, I've become stuck however on editing these objects in the array and then saving the array back to the Plist file again. I'm already reading the file like so... Array = [myArrays objectAtIndex:arrayCounter]; //This tells it which Array to load. myObject = [Array objectAtIndex:0]; //This reads that object in the array. (This is what I want to edit.) I was wondering how I would go about editing that object (it's a string) and then saving it back into the array and then saving that array

Not able to write to Plist

怎甘沉沦 提交于 2019-11-29 16:59:48
I have a very basic question about how to write to a plist. I added a "Here.plist" file to my resources folder. The following is my code: NSString *path = [[NSBundle mainBundle]pathForResource:@"Here" ofType:@"plist"]; NSArray *array = [[NSArray alloc]initWithObjects:@"First", @"Second", @"Third", nil]; [array writeToFile:path atomically:YES]; "Here.plist" is still empty after executing the code. I even tried using a NSDictionary as follows: NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"firstValue", @"First", @"secondValue", @"Second", @"thirdValue", @"Third", nil]; [dict

What are some advantages of using Core Data? (as opposed to plist)

試著忘記壹切 提交于 2019-11-29 16:42:32
问题 I am relatively new to iOS and programming, and I made an app before, but it used a plist for storage, which I saved to the documents folder. Now, I am thinking about switching over to Core Data, but it looks a little complicated, and I'm not sure if it will work for what I want. I am going to have a bunch of data which I need to graph, so I'm not sure if Core Data is best for this, as it seems that I cannot create an array type in the .xcdatamodeld file. What are some other advantages of

How to add and get the values from .plist in iOS

坚强是说给别人听的谎言 提交于 2019-11-29 16:26:11
问题 I am implementing a application based on web services. In that I need to add a string as property in .plist and I need to get the value from the .plist whenever I need in the code. 回答1: Here is a code sample: NSString *path = [[NSBundle mainBundle] pathForResource: @"YourPLIST" ofType: @"plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path]; id obj = [dict objectForKey: @"YourKey"]; 回答2: NSBundle* mainBundle = [NSBundle mainBundle]; // Reads the value of the custom

iphone SDK:Can write data to plist on Simulator but can't do same thing at Device?

江枫思渺然 提交于 2019-11-29 15:29:18
Why I can write information to plist on simulator But can't do this on real iphone/ipod device ???? Is there exist an absolute path to put a .plist file in xcode project ??? Thanks for all reply and answers ~ code : this how I write text to plist from textfield NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Password" ofType:@"plist"]; NSMutableDictionary *propertyList = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath]; [propertyList setValue:serialNumber.text forKey:@"serial_number"]; You can only write to your application's sandbox directory. Below is a function

Reading plist file

蓝咒 提交于 2019-11-29 13:33:20
问题 I created plist with big base of different animals in it (keys) and added this plist in my project. Type of every animal is NSDictionary. In every dictionary there are 5 more keys - characteristics of these animals (). I would like to go through every animal and if I match a certain characteristics of this animal, I put this animal in another array. So, I tried to make a code: NSArray *newArray = [[NSArray alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"animals" ofType:@