Questions tagged [nskeyedunarchiver]

NSKeyedUnarchiver, a concrete subclass of NSCoder, defines methods for decoding a set of named objects (and scalar values) from a keyed archive. Such archives are produced by instances of the NSKeyedArchiver class.

NSKeyedUnarchiver, a concrete subclass of NSCoder, defines methods for decoding a set of named objects (and scalar values) from a keyed archive. Such archives are produced by instances of the NSKeyedArchiver class.

A keyed archive is encoded as a hierarchy of objects. Each object in the hierarchy serves as a namespace into which other objects are encoded. The objects available for decoding are restricted to those that were encoded within the immediate scope of a particular object. Objects encoded elsewhere in the hierarchy, whether higher than, lower than, or parallel to this particular object, are not accessible. In this way, the keys used by a particular object to encode its instance variables need to be unique only within the scope of that object.

Click Here for class reference.

203 questions
3
votes
1 answer

Swift iOS ARKit Load ARWorldMap Data from File NSKeyedUnarchiver NSKeyedArchiver

I'm trying to save then load an ARKit ARWorldMap to a local file. I seem to have the saving working fine: func saveWorldMap() { ARView?.session.getCurrentWorldMap { [unowned self] worldMap, error in guard let map = worldMap else {…
Geoff H
  • 3,107
  • 1
  • 28
  • 53
3
votes
1 answer

Catching exceptions when unarchiving using NSKeyedUnarchiver

We've got a Swift class which inherits from NSObject and implements NSCoding. We need to change the name of the class in code and in the archives on disk. Fortunately, we don't need to retain the data. Wiping the cached files and returning default…
Dale Myers
  • 2,703
  • 3
  • 26
  • 48
3
votes
1 answer

NSKeyedArchiver.unarchiveObject Swift 3 iOS 10

I've been searching for an answer for this question but I couldn't find any, the similar ones don't have an answer at all. Basically, I want to save data with NSKeyedUnarchiver.archiveRootObject() and load it with .unarchiveObject(withFile). It was…
Smarambas
  • 171
  • 2
  • 10
3
votes
1 answer

How to convert NSKeyedArchiver objects over new versions

I just released an app to the app store and one of my patrons let me know that I should change the data type that I was previously storing as an Integer, using the NSKeyedArchiver, to a Double. Easy enough to change the app's data model but when I…
3
votes
1 answer

-[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class

I have an error I don't understand after I updated my app. I have an app already in the app store. I have some app specific data archived and stored in a file inside application support directory. I was reading and storing the data every time when…
MacP123
  • 151
  • 1
  • 7
3
votes
1 answer

Swift - NSKeyedUnarchiver unarchiveObjectWithData in NSMutableArray

var objects: AnyObject? = NSKeyedUnarchiver.unarchiveObjectWithData(data) How to turn objects into NSMutableArray ? I archived NSMutableArray.
Bogdan Bogdanov
  • 882
  • 11
  • 36
  • 79
3
votes
1 answer

Load SpriteKit levels from filename

For a game I'm creating, I want to be able to create a lot of custom levels that can be loaded easily. Each level should have a .sks interface file and its own SKScene subclass .swift file. Right now, this is working: extension SKScene { …
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
2
votes
1 answer

NSKeyedUnarchiver.unarchiveTopLevelObjectWithData return nil

I want to save an array of objects into UserDefaults and load it back. When trying to unarchive the data it always returns nil.. any idea? This is my object: class DbInsideLevel: NSObject, NSSecureCoding { static var supportsSecureCoding:…
ytpm
  • 4,962
  • 6
  • 56
  • 113
2
votes
0 answers

NSKeyedUnarchiver unarchivedObjectOfClass implementation gives error

I am updating an old Objective C app that uses 'NSKeyedUnarchiver unarchiveObjectWithData' which is now deprecated. The app archives an array consisting of custom objects that contain (among other things) another array of a different custom object.…
Bob
  • 559
  • 1
  • 5
  • 18
2
votes
0 answers

NSKeyedArchiver Unable to Save or Load Data When Trying to Persist Data in Swift

I've been working on a basic iOS Food Tracker using Apple's Developer tutorial. When I got to the "Persisting Data" step, I realized that the functions used have been deprecated, so I've searched online to find the updated/working version. I've…
JennyW23
  • 21
  • 2
2
votes
1 answer

I get a warning in my console when load data from Coredata

i have a small problem with my code. When I load data from my CoreData I get warnings in my consol but I don´t know why. I´m not a professional programmer and also google couldn´t really help me so now I´m here. I load my data like this: let context…
2
votes
1 answer

NSKeyedArchiver deprecated method problem

Just a little background info. I lost my ability to speak a few years ago and learned how to code specifically to make a good text to speech app for myself. Amazingly a lot of others find it useful. Apple reports around 15,000 sessions per week. It…
d.altman
  • 355
  • 4
  • 15
2
votes
0 answers

Can't unarchive worldMap(ARKit) from Firebase using NSKeyedUnarchiver.unarchivedObject

I try to upload and unarchive World Map from firebase (which was previously serialized and loaded there), but I catch an error. Could you help me with my code. What am I doing wrong? Thank you. @IBAction func downloadButtonAction(_ sender: Any) { …
lera
  • 63
  • 7
2
votes
1 answer

NSKeyedUnarchiver issue when moving model to framework

I have moved part of my code into a separate framework, and that framework contains a model used by the app to persist data to CoreData. Now when I try to launch the app, and it tries to restore state from CoreData, I get the following…
2
votes
1 answer

Decoding array of URL objects using NSKeyedUnarchiver

I'm trying to decode an array of URL objects using NSKeyedUnarchiver. Here is the code: let urlArray: [URL] = [URL(string: "https://apple.com")!, URL(string: "https://google.com")!] do { let archivedUrls = try…
Julien
  • 81
  • 1
  • 5
1 2
3
13 14