nskeyedarchiver

How do I serialize an object to file using NSKeyedArchiver in NSPropertyListXMLFormat_v1_0 format?

Hopefully that title is clear enough. Anyways, it seems: [NSKeyedArchiver archiveRootObject:rootObject toFile:path]; is restricted to NSPropertyListBinaryFormat_v1_0. I need the format to be human readable [so xml]. If you're interested, this is part of project I'll eventually put up on github with a blog post about "How to Unit Tes...

Loading a Singleton's state from NSKeyedArchiver

I have a class that I've made into a singleton and am able to save it's state using an NSKeyedArchiver, but I can't wrap my head around pulling it's state back out. In the function that does the loading I have Venue *venue = [Venue sharedVenue]; NSData *data = [[NSMutableData alloc] initWithContentsOfFile:[self dataFilePath]]; NSKeyedU...

Archiving and Unarchiving results in Bad Access.

I'm having trouble setting up a model object to save the visual state of user generated CALayers in a simple graphics application for the iphone. I'm attempting to save the background color and frame of all the current layers on screen by passing those properties to model objects which implement the NSCoding protocol and then into an NS...

Versioning a persistent keyed archive?

For my current app I'm using the NSKeyedArchiver approach to persist my objects to the iPhone between launches. I'm wondering if it makes sense to tag this file when it's created with a version number so that in the future when the app revs we'll know what kind of data we're dealing with should migration be necessary. Is this recommended...

IPhone - NSKeyedUnarchiver memory leak

I am using NSKeyedUnarchiver unarchiveObjectWithFile: to read in application data. When running with Leaks in Instruments, I am told that the following produces a leak: { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; ...

Archiver Securing SQLite Data without using Encryption on iPhone

I'm developing an iphone app that uses Core Data with a SQLite data store and lots of images in the resource bundle. I want a "simple" way to obfuscate the file structure of the SQLite database and the image files to prevent the casual hacker/unscrupulous developer from gaining access to them. When the app is deployed, the database file ...

Will longer keys make an NSKeyedArchiver file significantly longer

When I fill in the encodeWithCoder: for objective c classes for an iPhone app will it make make the archive file larger if I use long keys as opposed to short keys for all of my variables? For example if I use really long keys like this: [coder encodeBool:myBoolean forKey:@"My_Excesively_Long_Boolean_Key"]; will it make the archive f...

iPhone app loses file

I am writing an iPhone app – a client for some social network. The app support multiple accounts. Info about accounts are stored in a keyed archive. A method used for saving: - (void) saveAccounts { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:...

Problem reading a string from an NSDictionary inside an NSMutableArray stored using NSKeyedArchiver.

I'm saving some data using a series of NSDictionaries, stored in an NSMutableArray and archived using NSKeyedArchiver. I'm basically trying to save the states of several instances the class 'Brick', so I've implemented a getBlueprint method like this (slimmed down version) -(id)getBlueprint { // NOTE: brickColor is a string NSD...

Possible to reliably open AND edit an NSKeyedArchiver's archive?

I'm using something like the code below to save an NSDictionary of objects to the device. Is there a way to open this archive, drill down into the Dictionary items that it contains and, ideally, edit the data? My guess is no, not reliably, as the optimization done when saving makes the archive difficult to interpret...at least it appears...

UserDefaults/KeyedArchiver Frustrations

I'm working on a homework app that uses custom Assignment objects for each assignment. I am trying to store an NSMutableArray (casted to an NSArray via initWithArray:) in standardUserDefaults but I'm having trouble with saving and reloading the array. I have a table view from which you can choose to add a new assignment (which loads N...

NSKeyedUnarchiver objects getting broken?

I have an array that I'm saving to NSUserDefaults, containing an array of my custom class Assignment, which conforms to the NSCoding protocol. The array saves and loads properly, and I can verify that the retrieved first object of the array is of the class Assignment. The problem happens when I try to access ivars of the Assignment objec...

Why am I getting "does not support archiving" in my NSWindow subclass ?

Hi all - I have the following class: @interface SpWindow : NSWindow <NSCoding> { BOOL _editMode; SpBgView *bgView; } ... ... which I then call archive on. My encode method is as follows: - (void) encodeWithCoder:(NSCoder *)aCoder { NSLog(@"encodeWithCoder CALLED FOR SpWindow"); [super encodeWithCoder:aCoder]; NSLog(@"SpWind...

NSKeyedArchiver internal format

Hello I need to load NSKeyedArchiver classes to C++/CLI counterparts. Is there any way to get internal format of NSKeyedArchiver? Another option is to rewrite whole saving and opening code into pure C++ for both Mac and Windows. Thanks a lot. ...

Will using an NSKeyedArchiver/NSCoder persist even after an application update?

Hi, I have NSKeyedArchiver and NSCoder data being persisted (as .txt files) and working great. When I deploy new builds to the iphone, the text files are still present - in other words, they are not being written over. However, I want to make sure that the text files will persist when an itunes delivered update of my application is m...

Using NSKeyedArchiver and NSData to send UIImage over bluetooth

I was wondering if it is possible to send a UIImage over bluetooth after encoding it into a NSMutableData using NSKeyedArchiver. This is what I had in mind: NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:[UIImage imageN...

How to create a plist (NSKeyedArchive) ?

Hey, At the moment I am trying to get comfortable with NSKeyedArchiving. Until now I don't get it. I've got an example plist which is archived. How can I make such an archived plist file? I've some values but no idea on how to create that. The docs didn't help me either... Hopefully you can help me. Thanks a lot. ...

Why does NSMutableArray Count crash my app?

I've ran into a problem. Everytime I'am starting my app it crashes. Heres me code. The Debugger Says: [list count] crashes the app. I have no idea. NSLog(@"%@", self.list); gives me one item as expected... if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { data = [[NSData alloc] initWithContentsOfFile:filePath]; unarc...

Encode NSArray or NSDictionary using NSCoder

I was wondering whether or not it is possible to use the NSCoder method: - (void)encodeObject:(id)objv forKey:(NSString *)key to encode either an instance of NSArray or NSDictionary. If not how do you go about encoding them? I am trying to use NSKeyedArchived / NSKeyedUnarchiver to send data between phones using GameKit. I tried it an...

Animation of NSImage gets lost after archiving it with NSKeyedArchiver

Following situation: I have an instance of my NSObject sublcassed object. One of it's properties is a NSImage. After instanciating the object I convert it with NSKeyedArchiver to data, send it over the network, unarchive it with NSKeyedUnarchiver and display the image in a NSImageView (setAnimates: YES). Until here there are no problems...