FAQ Database Discussion Community


How to save list of own classes in a plist in XML format using NSKeyedArchiver (or other mechanics)?

ios,xml,swift,plist,nskeyedarchiver
I manage to write a plist in binary format to disk. But I do not manage to write the data in XML format. I read this should be possible, but there is no sample code or documentation doing this. Code for storing which works: var listofbookmarks = [Bookmark]() // <-...

Edit an existing plist in iOS

ios,objective-c,plist
Good Morning, I am creating my first iphone app so bear with me. I have created a plist and have attached a picture so you can see how I set it up. I'm trying to add another Item under Clients, which has 3 keyvaluepairs in it. This is what I...

Not able to set screensaver idle time as root

osx,plist,cfpreferences
Script i used is #!/bin/sh # grab current user curUser=`ls -l /dev/console | cut -d " " -f 4` # grab the system's uuid if [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` != "00000000-0000-1000-8000-" ]]; then macUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" |...

read/write to array plist with Swift

ios,uitableview,swift,plist
Im trying to read a plist that contains an Array of Ints . This is my first time using them , and i can read them in fine , but the plist doesn't update when i write to it. here's my code for the reading and writing.. class FavouritesManager {...

Adding dictionary in plist file

ios,objective-c,xcode,nsdictionary,plist
I need to add items in my plist (organizations.plist) My plist is organized in the following way: I have a root dictionary, and in this one, I have others dictionary... <?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>1</key> <dict> <key>Address</key> <string>Address</string> <key>City</key> <string>City</string>...

Watchkit -application: handleWatchKitExtensionRequest error

ios,objective-c,xcode,plist,watchkit
I'm getting the following error when requesting a dictionary of XML items via the above method: > NSLocalizedDescription=The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:] I have no problem passing an NSDictionary consisting of an NSMutableArray of NSStrings. From the interface controller: - (void) requestFeedsFromPhone {...

NSKeyedUnarchiver. Loading array of custom objects from plist

ios,objective-c,plist
I am trying to load my .plist file Into array of my cusom objects, called Property. Here is Property.h: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface Property : NSObject<NSCoding> { int price_base; float state; float infrastructure; } -(id)initWithCoder:(NSCoder *)decoder; -(void)encodeWithCoder:(NSCoder *)aCoder; @end And Property.m: #import "Property.h" @implementation Property -(void)encodeWithCoder:(NSCoder *)aCoder {/*No need...

How to iterate concisely through @properties on an NSObject subclass to set properties from a plist?

cocoa,nsarray,nsdictionary,plist,nsobject
Say I have a subclass of NSObject (let's call it 'BSObject') with the following properties: NSString *name; NSNumber *num; I have an NSMutableArray of BSObjects (let's call that one 'BSCollection'). For storage on disk, I have a property list which is an array of dictionaries. The BSCollection is represented by...

Unable to encrypt and decrypt data in plist

ios,encryption,plist,rncryptor
I'm trying to encrypt the saved plist data using RNCryptor and decrypt it. the output is all gibberish in encrypted file but am not able to get the anything after decryption. NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"data.plist"]]; NSError *error1; bac = [RNEncryptor encryptData:data withSettings:kRNCryptorAES256Settings password:@"abcdef" error:&error1]; NSString *pathToDesktop = [NSString...

ERROR ITMS-90075: The application-identifier entitlement is missing

plist,itunesconnect,testflight,entitlements
When attempting to submit an app to Apple iTunes Connect TestFlight, I get the following error: ERROR ITMS-90075: "This bundle is invalid. The application-identifier entitlement is missing; it should contain your 10-character Apple Developer ID, followed by a dot, followed by your bundle identifier." How should this be fixed in...

Where should the sensitive information be stored?

ios,core-data,plist,nsuserdefaults,nsdocumentdirectory
Is it fair to store sensitive data in NSUserDefaults ? I have read that this is a big issue because, NSUserDefaults are stored in plist in binary format, with no encryption, and is stored in your app’s directory. This means that any user, even the “noobiest” one, can tinker with...

Correctly casting info.plist entries to NS* types

ios,objective-c,casting,plist,info.plist
I want to write a helper class to get values from my info.plist and have them be cast to their correct type. So, if I try to access a property that's actually a number as a date, I should get back nil or an error. I'm having trouble coming up...

Populate Plist to UITableview

ios,objective-c,uitableview,plist,unrecognized-selector
I have a problem with my code and i can't figure out what's wrong. My code is this : @implementation FirstViewController { NSDictionary *countriesDetails; NSArray *countriesList; - (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"countries" withExtension:@"plist"]; countriesDetails = [NSDictionary dictionaryWithContentsOfURL:url]; countriesList = countriesDetails.allKeys; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section...

How to add Dictionary to Plist in SWIFT

ios,swift,plist
i have a dictionary of type as below var favoriteGooglelocations = [Int:GoogleItems]() where GoogleItems is class. class GoogleItems: NSObject { var name:String? var address:String? var distance : String? var googleLocation: CLLocation? var isStar : Bool? } And i am writing to the dictionary as : var newLocation = GoogleItems() newLocation.name...

How to save data to multidimensional array in plist file

swift,multidimensional-array,plist
I would like to save some configuration data to my plist file which contains arrays and regular variable types. It looks like this: (http://s10.postimg.org/f2xpgur1l/plist.png) (sorry I can not attach any image) My function which do this looks like so: // Saves the data into a plist file func saveObject(i_fileName: String,...

Can't get content from plist to UITableview

ios,iphone,uitableview,xcode6,plist
Hello i am getting this error and i can't find where is the problem my code is this : @implementation ViewController { NSDictionary *animalDetails; NSArray *justAnimalNames; - (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [[NSBundle mainBundle] URLForResource: @"animals"withExtension:@"plist"]; animalDetails = [NSDictionary dictionaryWithContentsOfURL:url]; justAnimalNames = animalDetails.allKeys; // Do any additional setup...

How writeToFile in a .playground?

swift,save,plist,swift-playground
I have edited a .plist file. How I understood it: because of sandboxing it is only possible to read files inside the .playgrounds file in a Resources directory. But how is it possible to write the edited file to this folder? // read file let xmlPath: String = NSBundle.mainBundle().pathForResource("Settings", ofType:...

read array from plist and only return item if match was found

ios,swift,plist,nssortdescriptor
i'm trying to work my way through a plist... Now i wanted to only fetch item 1 if it was a genre of Soft how do i achieve this ? i'm trying to sort my way through it but it doesn't work... var path = NSBundle.mainBundle().pathForResource("radioChannels", ofType: "plist") self.menuItemArray =...

strange error with plist file

ios,swift,sprite-kit,plist
I have a plist file where I added level info. It is setup as follows: It has a dictionary called patterns, then it has an array called 1, and that array contains n items, which are all dictionaries. These items have the 3 booleans and three numbers. This is my...

poet.books throw fatal error: NSArray element failed to match

ios,swift,ios8,plist,fatal-error
please help, this error broke my app. I have two classes: First Class-Poets class Poets { var poetName:String = "" var poetYearsOfLife:String = "" var poetImage:String = "" var poetBiography:String = "" var books=[Works]() } Second class Work class Works { var nameWork:String = "" var workPoet:String = "" }...

Unexpectedly found nil while unwrapping an Optional value - Plist

ios,swift,plist
i am trying to read from propriety list using swift but im getting this error, and thats the code im using to read from my plist : Arrays i'm using : var recipeNames :[String] = [] var recipeImages :[String] = [] var recipeTime :[String] = [] In viewDidload : var...

Running Python Script at startup of OSX

python,osx,plist,launchctl
I have a Python script that I want to execute as soon as I login into my Mac . I have tried various methods on the internet. But none of them seem to work . I tried placing the com.username.scriptname.plist file in Library/LaunchAgents. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD...

Delete UITableViewCell and synchronize with Plist

ios,uitableview,swift,plist
i have a class as class DropOffFrequentVC: UIViewController { @IBOutlet weak var tblView: UITableView! var googleDicCount : Int? var foursquareDicCount : Int? var favoriteGooglelocations = [Int:GoogleItems]() var favoriteFourSquarelocations = [Int:FourSquareItems]() i have a UITableViewCell as func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { ..... if indexPath.section == 0 {...

How can I detect an error when searching through a property list?

ios,objective-c,plist
On the first screen of my app, you enter a 4 digit code. When you press "Done", it saves the code automatically and the app switches views to the next screen. On the new screen, it pulls up the saved code and searches through a plist trying to find the...

How do I reach Test Target Bundle Plist-file from production code under the Test Target?

ios,swift,testing,properties,plist
I need to flag certain test-specific situations from production code, and since precompiled macros no longer exist in swift (and since the Other Swift Flags seems to work on a target basis, but not on a test-target specific basis) I thought I could use the test plist to access properties...