plist

Use a Plist dictionary for App settings

情到浓时终转凉″ 提交于 2019-12-06 08:12:59
问题 I want to be able to use a plist for settings Im implementing in my app. I want a dictionary "Settings" to hold my arrays, such as "Debug", "Option 1", Option 2", etc. How would I access "Debug"array under the "Settings" dictionary? NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *myPlistPath = [documentsDirectory stringByAppendingPathComponent:@"ProfileManager.plist"];

iOS 8 Swift Read Plist

半腔热情 提交于 2019-12-06 08:08:16
问题 I want to read values from a plist file as integers. I have the following code: let path = NSBundle.mainBundle().pathForResource("savedState", ofType: "plist") let dict = NSDictionary(contentsOfFile: path!) let players: AnyObject = String(dict.valueForKey("players") as NSString) let level: AnyObject = String(dict.valueForKey("level") as NSString) let numPlayers = Int(players as NSNumber) let playLevel = Int(level as NSNumber) The let players: and let level: crash my app. I know this should be

How to add custom ttf fonts to iphone application?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 07:52:37
问题 I have problem of adding fonts to my iphone application I want to know how to do it, and let me specify that I am not using IB and I have inherited the UILabel and making label of that new class, Please Help me out, I have downloaded the ttf and want to use in my app, I added "Fonts Provided by application" to my app and then added the font name with ttf extension, but still didn't work, what should I do ? @implementation RRSGlowLabel - (id)initWithFrame:(CGRect)frame { self = [super

Edit an existing data in plist

和自甴很熟 提交于 2019-12-06 07:45:02
问题 How can i override an existing data in a plist after checking if the data is already present or not, through coding In Detail: I am saving username and password in my plist file located in document directory. Now if user selects an change password option, the plist should check if his username exists or not. if it exists then the new password that he is entering should override the existing password in the plist. can anyone help me with some piece of sample code 回答1: You can't change the

Write into Settings bundle in Swift

瘦欲@ 提交于 2019-12-06 05:59:51
I have created an app with settings bundle in it and the app configuration can be changed. Reading from Settings bundle is done. I am using below code. let defs: NSUserDefaults = NSUserDefaults.standardUserDefaults() defs.synchronize() var settingsBundle: NSString = NSBundle.mainBundle().pathForResource("Settings", ofType: "bundle")! if(settingsBundle.containsString("")){ NSLog("Could not find Settings.bundle"); return; } var settings: NSDictionary = NSDictionary(contentsOfFile: settingsBundle.stringByAppendingPathComponent("Root.plist"))! var preferences: NSArray = settings.objectForKey(

Save array of objects with properties to plist

一曲冷凌霜 提交于 2019-12-06 03:29:02
问题 I have a Mutable Array containing different objects such as strings, UIImage , etc. They are sorted like this: Example: BugData *bug1 = [[BugData alloc]initWithTitle:@"Spider" rank:@"123" thumbImage:[UIImage imageNamed:@"1.jpeg"]]; ... ... NSMutableArray *bugs = [NSMutableArray arrayWithObjects:bug1,bug2,bug3,bug4, nil]; So basically it's an array with objects with different properties. I Tried to save a single string to a file with the next code and it's working fine but when I try to save

Get NSUserDefaults plist file from device

情到浓时终转凉″ 提交于 2019-12-06 02:26:15
问题 When testing my app on the simulator, I like the ability to edit, or even trash the apps plist file (which contains the NSUserDefaults) from the iPhone Simulator folder. This proves useful when testing (e.g. your app stores a dictionary in there, but you change the model/keys that you use for this data, and therefore need to remove the dictionary stored). Is it possible to access this file on device (for your own app), without jailbreak? Thanks in advance 回答1: The file is in Library

iOS Enterprise Deployement: Clicking on itms-services link results in “Cannot connect to [domain]” error

醉酒当歌 提交于 2019-12-06 01:01:04
问题 In an effort to deploy an enterprise iOS app, I've created the following link: Unencoded version (for easy reading): <a href="itms-services://?action=download-manifest&url=https://example.com/api/distribution/ios?token=abc123">Download</a> Encoded version: <a href="itms-services://?action=download-manifest&url=https%3A%2F%2Fexample.com%2Fapi%2Fdistribution%2Fios%3Ftoken%3Dabc123">Download</a> The link is properly encoded, as discussed here and here. Assuming the user's token is valid, a

Xcode 10 storyboard and info.plist git diff is not properly showing

為{幸葍}努か 提交于 2019-12-05 22:18:21
Am facing a strange issue on my Xcode 10 . Whenever I get conflict on storyboard or plist , Xcode does not showing me the proper way to resolve conflicts. See the screenshot which is an example of storyboard case. If I get the conflict on plist file, then I can't even open it ( Xcode saying the file is not proper format). Right now am using Xcode 9.4 to resolve this issue. Is there a way to fix it in Xcode 10 . Thanks in advance. If I get the conflict on plist file, then I can't even open it (Xcode saying the file is not proper format) Of course you can’t. Once the conflict has occurred, and

Write data to plist

怎甘沉沦 提交于 2019-12-05 21:52:32
I would like to read data from a plist, add some elements and the write the data to a plist.(update a plist). I want to have the plist hold an array of dictionaries, read this array into my app, add dictionaries and then write the array back to the plist. How is this done? Im also not sure where and how to create the plist on the apps first launch. or should it be placed in the bundle from the beginning? Another thing I am not sure about is if the plist dictionaries can hold e.g. CLLocations as values for keys? Will it be saved correctly or would the CLLocation need to be broken into lat and