Questions tagged [nskeyedarchiver]

NSKeyedArchiver, a concrete subclass of NSCoder, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyedArchiver’s companion class, NSKeyedUnarchiver, decodes the data in an archive and creates a set of objects equivalent to the original set.

NSKeyedArchiver, a concrete subclass of NSCoder, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyedArchiver’s companion class, NSKeyedUnarchiver, decodes the data in an archive and creates a set of objects equivalent to the original set.

A keyed archive differs from a non-keyed archive in that all the objects and values encoded into the archive are given names, or keys. When decoding a non-keyed archive, values have to be decoded in the same order in which they were encoded. When decoding a keyed archive, because values are requested by name, values can be decoded out of sequence or not at all. Keyed archives, therefore, provide better support for forward and backward compatibility.

Click Here for class reference

570 questions
0
votes
2 answers

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.
Filip Kunc
  • 631
  • 1
  • 8
  • 19
0
votes
1 answer

iOS NSKeyedArchiver unarchive returns empty array

I'm having an issue with NSKeyedArchiver which has been puzzling me for quite a while now and can't seem to pinpoint the error. I have a mutable array consisting of Objects of the Class "Device". In my appDelegate I keep a mutableArray of Devices…
Gilles Lesire
  • 1,237
  • 17
  • 33
0
votes
1 answer

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…
Arman
  • 856
  • 2
  • 10
  • 19
0
votes
2 answers

Using NSKeyedArchiver/Unarchiver in custom getter/setter methods

I'm trying to use a NSKeyedArchiver/NSKeyedUnarchiver to store data for a class's property in a file in order to persist the state of the property between launches of the app. I have the property declared in MyClass.h like so: @property (nonatomic,…
RL2000
  • 913
  • 10
  • 20
0
votes
2 answers

Can I do partial saves with NSKeyedArchiver?

I have a database object and some photos objects. The database object contains an integer property and a mutable dictionary property. The integer keeps track of the next free number to use as a mutable dictionary key when I create a new photo…
Gallymon
  • 1,557
  • 1
  • 11
  • 21
0
votes
1 answer

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…
gargantuan
  • 8,888
  • 16
  • 67
  • 108
0
votes
1 answer

Keeping data on screen when switching views with nskeyedarchiver

I have been using xcode for ~9 months now and I am close to finishing my app but have 1 small problem... A little bit of background. I have a button that randomly spits out some data [workouts in this case]. In that window there is also a button to…
0
votes
0 answers

NSStringFromClass() exc_bad_access crash

I'm experiencing this crash in my application and I can't seem to figure out what is going wrong. I've got an object with a property that holds on to a Class struct. I declare it like this: @property (nonatomic, assign) Class myClass; Now, I'd…
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
0
votes
1 answer

How to find archived object file?

I am doing the following to store an object as an archive: [[NSUserDefaults standardUserDefaults] setObject:[NSKeyedArchiver archivedDataWithRootObject:self.shapeLayers] forKey:@"mySavedArray"]; I know it works fine as I'm able to reload it.…
Ser Pounce
  • 14,196
  • 18
  • 84
  • 169
0
votes
1 answer

Using NSKeyedArchiver to save an NSDate object

I have a NSDate object NSDate* time = [NSDate date]; I'm trying to save it using NSKeyedArchiver using the following NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *saveFile = [[paths…
Tiddly
  • 1,620
  • 3
  • 21
  • 43
0
votes
0 answers

Include additional object when archiving with NSKeyedArchiver

I'm trying to archive a tree of objects using NSKeyedArchiver. All nodes in the tree support NSCoding, but I don't have access to the source code, so I can't change anything. However, I'd like to include an additional NSString with some of the nodes…
DrummerB
  • 39,814
  • 12
  • 105
  • 142
0
votes
1 answer

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 =…
Aleksejs Mjaliks
  • 8,647
  • 6
  • 38
  • 44
0
votes
1 answer

Trouble Using NSKeyedUnarchiver during init

I have created a FacebookManager singleton that gets called on a background thread when my app launches. Everything is working just fine with the facebook manager the singleton, the app etc. However, when the app first launches, it is quite a few…
zeeple
  • 5,509
  • 12
  • 43
  • 71
0
votes
2 answers

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…
Jamvert
  • 76
  • 5
0
votes
1 answer

How to Archive two strings into NSData by using NSKeyedArchiver

I have NSMutableArray and a NSString. How to archive these two in to a NSData by using NSKeyedArchiver in IOS6, Xcode4.6
Vineesh TP
  • 7,755
  • 12
  • 66
  • 130