property-list

PropertyListEncoder is ignoring .binary outputFormat

我是研究僧i 提交于 2021-02-11 13:49:15
问题 I wrote a little sample bit of code to document how to encode Swift objects as property lists, using PropertyListEncoder . The code works, but I wanted to output to a binary property list. (Those are faster and more compact) However, it seems the PropertyListEncoder is ignoring my setting outputFormat = .binary and writing the file as XML anyway: Here is the code (a MacOS command line tool, just because that's a low-overhead way to write some test code: ) import Foundation var array = ["one",

How to put a Property List in the Documents folder of my app when app is shipped?

落花浮王杯 提交于 2019-12-25 00:08:19
问题 I have several tableviews in my app and the data source for each tableview is a property list. Currently I have the propertylists saved in the application bundle. However, thats only because I created them in XCode and they are automatically saved in the documents folder. This is fine as when the app ships, thats where they need to be. However, I would like to put a copy of the property lists in the documents folder of my app as well when it ships. How can I do that? I mean Can I program

modifying a Plist from command line on Mac using Defaults

送分小仙女□ 提交于 2019-12-20 08:40:48
问题 Does any one know how to modify a Plist file from command line using defaults ? Currently there are two Dictionaries under the URL types array; I need to add another. Every command i've tried have either replaced the entire dictionary, or created a new array called URL types instead of editing it. Any ideas of how this can be done in defaults (the console Mac app) and not PlistBuddy? 回答1: Open the Info.plist in a text editor to see the actual identifiers. defaults write Absolute/Path/to/Info

How to store relatively static but configurable information

馋奶兔 提交于 2019-12-13 05:16:39
问题 I have a table (dictionary of dictionaries) to store mapping of integers to strings. I have types and sub-types. e.g. type 1=>fruits and sub-type 1=>apple. The mapping shall be configurable in my setting interface, but for the reset of the application, it's rather static. So I don't want to read from property-list every time I check the mapping. I'd like to only read once when program starts and only write when user changes setting. Where should I keep this table at runtime? I have two

Decode PropertyList using Swift 4 Codable PropertyListDecoder()

微笑、不失礼 提交于 2019-12-12 13:29:21
问题 Im trying to decode a plist using PropertyListDecoder() but when I get to the trying to access the keys, I get an error that says it's in the wrong format. I'm at a loss on what I'm doing wrong. Im under the assumption I can decode a Plist file the same way I can decode a JSON file right? I don't know, I'm still new to this. //struct for PLists struct AccessControl: Decodable { enum AccessControlKeys: String, CodingKey { case api } enum KeySecretKeys: String, CodingKey { case apiKey = "KEY"

Parsing specific JSON-like data (NextSTEP PList) from Ruby

落花浮王杯 提交于 2019-12-11 14:02:20
问题 i'm writing a client to a third-party API, and they provide data in a weird format. At first, it might look like JSON but it's not, and i'm a bit confused about how i should handle that. It's a key-value based format (much like JSON). Keys are separated by '=' from their values. Keys and values are wrapped within double-quotes. Dictionaries start with '{' and end with '}'. Arrays start with '(' and end with ')' Lines end with ';' (Excepted for arrays content) and end-of-line character (\r i

dyld: warning, unknown environment variable: DYLD_LIBRARY_PATH_64-bit

狂风中的少年 提交于 2019-12-11 03:06:04
问题 I used the bundled Property List Editor of Mac OS X Developer Tools to set an environment variable DYLD_LIBRARY_PATH_64-bit to the value path/to/dylib in the file ~/.MacOSX/environment.plist. I saved this file and logged out. Upon logging back in, the console displayed multiple messages of "dyld: warning, unknown environment variable: DYLD_LIBRARY_PATH_64-bit." I removed the entry from environment.plist with the Property List Editor, saved the file and logged out. I logged back in, and the

XCode: Quick open property list file e.g. info.plist as source code?

廉价感情. 提交于 2019-12-08 19:34:13
问题 In Xcode you can "quick open" files by selecting File/Open Quickly . When I enter the file name of a plist file, then this file is opened as "Property List". But often I want to open the file as "Source Code". How can I quick open property list files as source code? 回答1: The fastest method to open property lists in Xcode as source code is the following: Press ⌘+⇧+o to get the Quick Open Dialog Enter name of property list file e.g. " info.plist " and press "Enter" Open "Version Editor" ->

Handling CFNull objects in NSPropertyListSerialization

左心房为你撑大大i 提交于 2019-12-06 05:07:43
问题 In my application, I am trying to serialize a server response dictionary and writing it to file system. But I am getting error "Property list invalid for format" for some responses. The reason is CFNull objects in the server response. Now, the server response will keep on changing so I do not have a definite way to remove CFNull objects (). Below is my code: NSString *anError = nil; NSData *aData = [NSPropertyListSerialization dataFromPropertyList:iFile format:NSPropertyListXMLFormat_v1_0

Handling CFNull objects in NSPropertyListSerialization

走远了吗. 提交于 2019-12-04 10:01:26
In my application, I am trying to serialize a server response dictionary and writing it to file system. But I am getting error "Property list invalid for format" for some responses. The reason is CFNull objects in the server response. Now, the server response will keep on changing so I do not have a definite way to remove CFNull objects (). Below is my code: NSString *anError = nil; NSData *aData = [NSPropertyListSerialization dataFromPropertyList:iFile format:NSPropertyListXMLFormat_v1_0 errorDescription:&anError]; What is the best way to tackle this issue? How can I remove all CFNull objects