plist

What's the difference between a dictionary and an array?

假装没事ソ 提交于 2019-11-28 21:26:30
What is the difference between a dictionary and an array, especially when working with PLIST files? What are the advantages of using one over the other? Thanks! Both NSDictionary and NSArray are collection classes, i.e. the group together other objects. An NSArray is an 'ordered collection' - every item in the collection has an integer index, so there is an explicit order to the items. If you swap the order of items in the collection then the collection is no longer the 'same' as the order is different. An object may appear more than once in the collection. An NSSet is an 'unordered collection

How to read from a plist with Swift 3 iOS app

99封情书 提交于 2019-11-28 20:59:54
问题 -Disclaimer- I'm extremely new to iOS and Swift development, but I'm not particularly new to programming. I have a basic iOS application with Swift3 elements in it. I've created a plist file with some entries I want to read and display in my application. (No write access is necessary) How can you read a value for a given key for a bundled plist file, in Swift3? This seems like a really simple question to me, but a bunch of searching is making me question my whole conceptual approach. Helpful

Writing swift dictionary to file

天大地大妈咪最大 提交于 2019-11-28 20:44:26
There are limitations with writing NSDictionaries into files in swift. Based on what I have learned from api docs and this stackoverflow answer , key types should be NSString, and value types also should be NSx type, and Int, String, and other swift types might not work. The question is that if I have a dictionary like: Dictionary<Int, Dictionary<Int, MyOwnType>> , how can I write/read it to/from a plist file in swift? rintaro Anyway, when you want to store MyOwnType to file, MyOwnType must be a subclass of NSObject and conforms to NSCoding protocol. like this: class MyOwnType: NSObject,

Securing xml plists in Cocoa / Objective C

天涯浪子 提交于 2019-11-28 18:52:24
I am writing an application which reads information from am xml plist in the bundle upon startup. The information in the plist has been compiled through many days of work and I would like to ensure that it cannot be extracted easily from the app bundle by another party after distribution. Is there any way to secure or encrypt xml plists that one includes within your app bundle? Any help would be greatly appreciated please. There is no built-in encryption function in plist. Many people treats the compression as encryption. Here is what I would do, Make up an encryption key. write a tiny program

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

青春壹個敷衍的年華 提交于 2019-11-28 17:08:43
问题 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"

Where are ${EXECUTABLE_NAME} and ${PRODUCT_NAME} defined

早过忘川 提交于 2019-11-28 16:08:31
Where can I find information on how to modify these ${EXECUTABLE_NAME} ${PRODUCT_NAME} These are only displayed in .plist file but where are the actual values. If we can directly modify what ever we want in .plist why we need these. I am new that's why I'm having problem understanding these, I also looked into apple information Property list key reference but didn't find these ${} values. The PRODUCT_NAME is defined in the target's Build Settings in the Packaging section. It has the same name by default as your project. Edit: While PRODUCT_NAME is by default the name of the Target ( MyDemoApp

How to know which line of plist file is incorrect

限于喜欢 提交于 2019-11-28 15:58:19
问题 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? 回答1: Try running the following command in

Where is a Mac Application's NSUserDefaults Data Stored?

烂漫一生 提交于 2019-11-28 15:22:56
I am using NSUserDefaults to store some data in my application. NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:@"dummy string" forKey:@"lastValue"]; [prefs synchronize]; For testing purposes I need to see the System Preferences plist file where my NSUserDefaults data is saving on the Mac. I know where the iOS application user defaults are stored, but I don't know about mac application. Where is a Mac Application's NSUserDefaults Data Stored? They can be found in more than one place: ~/Library/Preferences/com.example.myapp.plist ~/Library/SyncedPreferences/com

How to write to plist successfully?

本小妞迷上赌 提交于 2019-11-28 14:41:58
I am having trouble writing my file into the plist after going through many tutorials, other people's problems and attempting it for myself. I can read the plist with no problems but I cant update it. Below are my codes on how I am writing my data into the plist. Correct me if I made any mistake. NSString *path = [[NSBundle mainBundle] pathForResource:@"EventAddress" ofType:@"plist"]; NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; NSArray* allmyData = [myDictionary allValues]; // creates and array to store only the event details NSMutableArray

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

一世执手 提交于 2019-11-28 12:59:26
问题 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) 回答1: You can't write to the main bundle in iOS, everything inside your Apps bundle