plist

Not able to write NSDictionary to plist file

雨燕双飞 提交于 2019-12-13 07:35:44
问题 Update: I am able to write tot he file when I change the following line [infoDict setObject:userList forKey:@"users"]; to [infoDict setObject:@"sampleString" forKey:@"users"]; so, there must be problem with the structure I'm trying to write to the file, any thoughts? I am trying to create a plist file and write to it at runtime in my iOS app. I am not able to write to it but I'm able to read though. The writeToFile method returns a 'NO'. When I manually try to manually open the file I created

Getting plist data in a order

此生再无相见时 提交于 2019-12-13 06:59:20
问题 I save my datas in plist. Once my app is deleted and reinstalled I planned to get those plist datas through iCloud. I have upload option to send file to cloud and retrieve when app installed new. Once app is deleted/reinstalled the plist data is retrieved with no issue. Now the problem is I save my files like this in a array and write to plist: Printing description of arrTemp: <__NSCFArray 0x175f7d90>( { Amount = "USD 100.00"; Category = ""; Currency = USD; Date = "Fri 31 Oct,2014"; DateSort

Sum of records in property list

五迷三道 提交于 2019-12-13 06:01:59
问题 How can I calculate the sum of all numbers in all dictionaries for the key for example "Hours"? Couldn't find any informations about that. Here is piece of my property list I'm talking about: <plist version="1.0"> <array> <dict> <key>Address1</key> <string>17 Stanley Road</string> <key>Address2</key> <string>Essex</string> <key>City</key> <string>Southend On Sea</string> <key>Email</key> <string>lmozdzen@gmail.com</string> <key>Lessons</key> <array> <dict> <key>LessonComment</key> <string><

Reading information from a Plist to use in TableView

丶灬走出姿态 提交于 2019-12-13 05:39:50
问题 I've checked the other posts, but non seem to answer my question, so here I go :) I've got a Plist, with the following contents: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>001</key> <dict> <key>Name</key> <string>Name1</string> <key>Number</key> <string>001</string> </dict> <key>002</key> <dict> <key>Name</key> <string>Name2</string> <key>Number</key> <string

Create plist file via code

好久不见. 提交于 2019-12-13 05:39:15
问题 I want to create a plist file like this: in code, and then it will be in the Caches folder. I already know how to fetch the data. 回答1: You can do it like this: //Create a Mutant Dictionary NSMutableDictionary *theMutantDict = [[NSMutableDictionary alloc] init]; //Fill it with data [theMutantDict setObject:@"John" forKey:@"Name"]; [theMutantDict setObject:@"Doe" forKey:@"Lastname"]; //Then search for cache dir NSString *libraryDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,

count items in plist array

流过昼夜 提交于 2019-12-13 05:37:53
问题 I am having difficult accessing the count of a chosen plist. In the previous view controller, the user selects from one of several buttons, each one corresponding to a particular plist. That plist is sent to the current vc as NSString * chosenPlist. I have NSLogged to see that the documents directory and the plistpath seem to be correct, but the array that I want to count is still 0. How can I count the number of items in the chosen plist? NSString * chosenPlistPlus = [chosenPlist

protecting plist in ipad app

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:28:57
问题 In my app I am saving service urls and their user/passwords in a plist in the documents directory currently. I want to move the user and passwords over to keychain and protect the plist files aswell. I tried using the keychainwrapper class given in this example, but couldn't figure out how to add items to it. how do i add an array of dictionaries containing user name and passwords into keychain, and protect my plist files aswell? 回答1: If you want to use keychain, best solution is using third

Nasty NSPropertyListSerialization Leak

十年热恋 提交于 2019-12-12 23:03:58
问题 NSString *anError = nil; id plist; plist = [NSPropertyListSerialization propertyListFromData:rawCourseArray mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&anError]; if (anError != nil){ [anError release]; } The above code causes a memory leak every time I call it. I am releasing the error but still there is a leak. I haven't seen any resolution to this issue. I posted this already and most respond that this is not a leak. But see here in the leak performance tool: I

-[NSDictionary initWithObjects:forKeys:]: count of objects (0) differs from count of keys (2)

自作多情 提交于 2019-12-12 18:23:21
问题 I am getting the error of -[NSDictionary initWithObjects:forKeys:]: count of objects (0) differs from count of keys (2)' here is my code in saving the plist. @interface setting : UIViewController{ UIDatePicker *datePicker; IBOutlet UILabel * morningtime; UIDatePicker *afternoonpicker; NSString*morningtime1; NSString*afternoontime1; IBOutlet UILabel *afternoontime; } @property (nonatomic,retain) IBOutlet UIDatePicker *datePicker; @property (strong, nonatomic) IBOutlet UIDatePicker

added custom key to info.plist, when I access from playground in Swift, it is nil

淺唱寂寞╮ 提交于 2019-12-12 14:15:13
问题 Using Xcode 7.2 (on Yosemite), I can't seem to access custom key from my info.plist from a playground: import UIKit var str = "Hello, playground" let app_id = NSBundle.mainBundle().infoDictionary?["MyAppID"] as? String Using the above code, app_id is nil. I expected it to be the String "TEST" I included it in my info.plist like this: Is there some limitation to playgrounds that I haven't read about? If I print all of the keys, my custom key is missing: let dict = NSBundle.mainBundle()