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

Does NSKeyedUnarchiver autorelease?

I'm doing some archiving to a property list and when I unarchive my data using NSKeyedUnarchiver I find that my app crashes if I release the object afterward. I was wondering if the finishDecoding message also autoreleases the object. Seems weird…
Lee Probert
  • 10,308
  • 8
  • 43
  • 70
0
votes
1 answer

UIImagePickerController Causes my app to crash!

In my app, a user can select an image, change the picture of a UIImageView to the new imge, and save the image to NSUserDefaults using NSKeyedArchiver. When the user selects the image and the - (void)imagePickerController:(UIImagePickerController…
0
votes
1 answer

How can I save CLLocation better?

I am trying to save my CLLocation location for future use in my app. I have come up with the following: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths…
0
votes
1 answer

SceneKit and NSKeyedArchiver

I am trying to archive my SceneKit scene for saving using NSKeyedArchiver. This is so I can save the scene allowing me to restore it at a later date. I am finding that the restored scene seems to ignore/lose the SCNTransformConstraints I have added…
BassetMan
  • 461
  • 6
  • 13
0
votes
1 answer

Is it possible to save a NSMutableOrderedSet to a NSData attribute in a NSManagedObject subclass?

I have a NSMutableOrderedSet property named currentSongsList on a NSObject subclass. I have a NSData property named currentSongsList on a NSManagedObject subclass. I want to archive the NSMutableOrderedSet property into the database, so that it can…
Carl Smith
  • 1,236
  • 15
  • 18
0
votes
1 answer

Some data from object either not saving or not loading

I am working on a simple app to track my daughter's hockey games. My problem is that when I stop and restart the app some of the data doesn't get loaded back in. (I'm checking with a log statement that just shows zero regardless of what was there…
tangobango
  • 381
  • 1
  • 4
  • 17
0
votes
2 answers

What is the best way to transport CGPoint between devices?

I am developing a turn-based game with swift, where everything has to be converted to NSData. Right now i have been stuck on the "NS-stuff" for many days. Because CGPoint is not an object but a struct, it can't be converted to NSData directly, and…
Sifeng
  • 713
  • 9
  • 23
0
votes
2 answers

NSKeyedArchiver not persisting data

So, my app queries an Amazon Dynamo DB database and retrieves a few kilobytes worth of data. What I want the app to do is download everything the first time, and then every time after, just download a timestamp to see if it has the most recent…
effendo
  • 93
  • 1
  • 8
0
votes
0 answers

NSKeyedArchiver strange behaviour - saves expired objects

I have been wracking my brain over this one for a couple of days now. I have player data stored in individual .plist documents which are created by NSKeyedArchiver. Everything works fine for the most part; however, when I delete one of these .plist…
Ray Richards
  • 117
  • 2
  • 11
0
votes
1 answer

Custom NSObject iniWithCoder not called

I have a custom object, LevelContent, which contains some properties. LevelContentconforms to NSCoding, and I have implemented encodeWithCoder: and initWithCoder: methods. I save and fetch the data to Parse.com. Saving works fine like this: NSData…
imas145
  • 1,959
  • 1
  • 23
  • 32
0
votes
1 answer

Swift compiler error while using NSKeyedArchiver

I get this compile error: Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1 with this function: func saveChanges()->Bool { var path = self.itemArchivePath() …
bhzag
  • 2,932
  • 7
  • 23
  • 39
0
votes
1 answer

NSKeyedUnarchiver SKSpriteNode not showing

My SKSpriteNode is not appearing in the view when I am restoring from a saved state. There are no errors or warnings during the save and restore process. I am saving my player class using this code: NSUserDefaults *defaults = [NSUserDefaults…
sangony
  • 11,636
  • 4
  • 39
  • 55
0
votes
1 answer

How to store object of NSObject Class using File Archiving

I am trying to store an object of NSObject Class using file archiving. When i tried [NSKeyedArchiver archiveRootObject:myObject toFile:@"filePath"]; and NSArray *myArray=@[myObject]; [NSKeyedArchiver archiveRootObject:myObject…
Karan Alangat
  • 2,154
  • 4
  • 25
  • 56
0
votes
1 answer

NSKeyedArchiver working on simulator but not actual device

I cannot seem to get NSKeyedArchiver working. I have a main ViewController, which has an NSMutableArray as an instance variable. The array is populated by multiple instances of a custom class. The custom class conforms to the NSCoding protocol and…
jfherrm
  • 71
  • 8
0
votes
0 answers

Wait until unarchiveObjectWithData method is done

I'm using archivedDataWithRootObject: / unarchiveObjectWithData: methods to serialize / deserialize a list of strings relative to images to load from the device in my app. So when unarchiveObjectWithData method is executed: [NSKeyedUnarchiver…
Jean Lebrument
  • 5,079
  • 8
  • 33
  • 67