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
2
votes
1 answer

NSKeyedUnarchiver doesn't decode CLPlacemark object from CoreData data attribute

I have a core data entity with a placemark data attribute in which I'm trying to store a CLPlacemark object. @interface ZJPlace : NSManagedObject ... @property (nonatomic, retain) NSData * placemark; I'm encoding the object like this:…
Zoë Smith
  • 1,084
  • 1
  • 11
  • 19
2
votes
2 answers

NSKeyedArchiver: How to archive an NSValue containing a custom struct

Is there any way I can use an NSKeyedArchiver to encode an NSValue that contains a custom struct?. I have an NSDictionary which contains structs wrapped in NSValues and I want to archive this as part of a larger object graph but I receive the…
Rory O'Bryan
  • 1,894
  • 14
  • 22
2
votes
3 answers

Writing and reading custom object to file IOS

i have this object. @interface SeccionItem : NSObject { NSString * title; NSString * texto; NSArray * images; } @property (nonatomic,strong) NSString * title; @property (nonatomic,strong) NSString * texto; @property…
Nanoc
  • 2,381
  • 1
  • 20
  • 35
2
votes
0 answers

Exc Bad Access while unarchiving data from iCloud using UIDocument

Hi i am using iCloud support for my application and using UIDocument for storage. I was able to save data to iCloud and fetch the same for first time. But when i deleted and reinstalled the app on device, the seems to crash with EXC BAD ACCESS while…
vinod
  • 51
  • 5
2
votes
2 answers

iOS: correct way to archive/unarchive a collection of objects

Just getting started learning iOS and I've got a really basic question: What's the correct way to archive/unarchive a whole collection of objects? I understand that you first need to implement the NSCoder protocol on the class. Assuming I've got a…
Andrew
  • 42,517
  • 51
  • 181
  • 281
2
votes
1 answer

CoreBluetooth fails when writing data encoded with NSKeyedArchiver?

I have an app that communicates iDevice-to-iDevice over Bluetooth LE using the CoreBluetooth framework. For one of my characteristics, I send a date encoded with NSKeyedArchiver (such as in the accepted answer for this question). When this happens,…
2
votes
1 answer

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…
Redrocks
  • 23
  • 3
2
votes
1 answer

NSKeyedUnarchiever loading line makes App crash on start

I have a problem with loading an Object with NSKeyedUnarchiever. My Object is a NSDictionary, which contains several Objects like Arrays and some of my own. They all conform to the NSCoding Protocol. I save my Object like this: [NSKeyedArchiver…
Redtoasty
  • 23
  • 2
2
votes
3 answers

How to Archive Two Arrays with NSKeyedArchiver

I've read a lot about archiving a single array with NSKeyedArchiver. But how would I save two arrays? I need to store/retrieve data for two view controllers within a UITabBarController. Each of the two view controllers create objects of the same…
Mark Newton
  • 75
  • 2
  • 4
2
votes
1 answer

NSKeyedUnarchiver SIGBUS BUS_ADRALN crash

I unarchive data in a NSFileWrapper with the following method which usually works very well: - (id)decodeObjectFromWrapperWithPreferredFilename:(NSString *)p { NSFileWrapper *wrapper = [self.fileWrapper.fileWrappers objectForKey:p]; if…
n.evermind
  • 11,944
  • 19
  • 78
  • 122
2
votes
1 answer

Is it necessary to use NSKeyedArchiver for standard Cocoa collections?

I recently wanted to store and retrieve NSArrays from user defaults, and I found and used the suggestion at Storing custom objects in an NSMutableArray in NSUserDefaults, which works fine. In retrospect, however, it would seem this is overkill if…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
2
votes
3 answers

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…
Joe Ricioppo
  • 812
  • 2
  • 10
  • 22
2
votes
1 answer

Xcode - Most Streamlined way of saving a lot of integers to a file

i am currently saving 30 integers to a file by creating a NSMutableDictionary and then using the NSKeyedArchiver to save it. @interface: NSInteger highScoreE; NSInteger highScoreM; NSInteger highScoreH; NSInteger highScoreI; NSInteger…
2
votes
1 answer

NSKeyedArchiver not saving custom object properties

Im having issues with NSKeyedArchiver. I'm trying to archive a dictionary, which in turn contains arrays of custom objects, Album and Song. Album and Song both inherent from NSObject and and conform to the NSCoding protocol. Here is how ive…
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
2
votes
2 answers

Saving an NSArray of custom objects

I've created a subclass of UIImage (UIImageExtra) as I want to include extra properties and methods. I have an array that contains instances of this custom class.However when I save the array, it appears the extra data in the UIImageExtra class is…
Smikey
  • 8,106
  • 3
  • 46
  • 74