Skip to main content
The 2024 Developer Survey results are live! See the results

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
0 votes
0 answers
42 views

unarchiveObject(with:) deprecated, is there a replacement when you are unwinding NOT a class but a vanilla [String: Any?]

req = ["a":nil, "b":3, "c":["d":3.3, "e":"e", "f":[]], "g":[]] Traditionally ("if js can do it we can do it too!&...
Fattie's user avatar
  • 13.9k
0 votes
2 answers
53 views

How to pass a class value adopting NSObject and NSCoding to a Swift function?

I would like to remove a warning when unarchiving objects so I tried to implement: func retrieveRepository(componentName:String, ofClass: AnyClass<NSObject, NSCoding>)->Any?{ let ...
Fabrizio Bartolomucci's user avatar
0 votes
1 answer
52 views

NSKeyedUnarchiver unarchivedObject: value for key 'NS.objects' was of unexpected class

I'm attempting to use NSKeyedArchiver in a ValueTransformer for SwiftData / Core Data. I'm getting an error using NSKeyedUnarchiver.unarchivedObject(ofClass: on an NSArray filled with NSMeasurements: ...
pkamb's user avatar
  • 34.6k
0 votes
0 answers
144 views

NSKeyedUnarchiver.unarchivedObject(ofClass... returns nil although its deprecated predecessor function worked

I have old code that uses NSKeyedUnarchiver.unarchiveTopLevelObjectWithData to unarchive data. let unarchivedData = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(archivedData) unarchivedData ...
Mike Nathas's user avatar
  • 1,343
0 votes
1 answer
84 views

Crash when unarchived data to CNContact

Hello I have a crash when unarchived data to CNContact : in line : var decodedContacts = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [CNContact.self], from: archived) as? [CNContact?] the error ...
Roei Nadam's user avatar
  • 1,780
0 votes
1 answer
32 views

NSCoder fails to decode object a second time if the object was already successfully decoded

I am using NSSecureCoding to encode/decode some objects and in the process of testing multiple ways to unarchive an object noticed that removing some print statements changed the decoder behavior. ...
Warpling's user avatar
  • 2,071
0 votes
0 answers
102 views

Unarchiving - iOS Swift - Can't get new method going

I've previously used NSKeyedUnarchiver.unarchiveTopLevelObjectWithData to unarchive data that I've previously archived and stored in a data model. I'm now trying to switch from NSKeyedUnarchiver....
Kent's user avatar
  • 1,725
-1 votes
1 answer
240 views

How to replace NSKeyedUnarchiver.unarchiveTopLevelObjectWithData with unarchivedObject when data is an array of Strings?

My project recently shows this error in Xcode: 'unarchiveTopLevelObjectWithData' was deprecated in macOS 10.14: Use unarchivedObject(ofClass:from:) instead I found this article which speaks to my ...
atoss's user avatar
  • 103
0 votes
1 answer
46 views

How do I properly use a getter as a selector in Objective-C? Getting deprecation warnings in modern Xcode

I'm using an old version of AFNetworking in an app, it works fine except I'm getting on deprecation warning from Xcode from this line in an initWithCoder method: self.queryStringSerializationStyle = (...
Doug Smith's user avatar
1 vote
2 answers
498 views

How to change the deprecated function NSKeyedUnarchiver.unarchiveObject(with:) to unarchivedObjectOfClass:fromData:error:

In my application, the user data getting after login is saved in the preferences as below. The xcode shows the warning that NSKeyedUnarchiver.unarchiveObject(with:) and NSKeyedArchiver.archivedData(...
RP89's user avatar
  • 111
5 votes
3 answers
2k views

How to replace NSKeyedUnarchiver.unarchiveTopLevelObjectWithData with unarchivedObject when data is a Dictionary

iOS 16.4 deprecates unarchiveTopLevelObjectWithData(_:) and should be replaced with unarchivedObject(ofClass:from:). When you archived a Swift Dictionary like [String: Any], how do you use the newer ...
Jordan H's user avatar
  • 54.6k
0 votes
0 answers
485 views

Can someone explain how to use NSKeyedArchiver and NSKeyedUnarchiver in Swift?

I have troubles understanding NSKeyedArchiver and NSKeyedUnarchiver in Swift. This is some example code I have been given to get a picture of its use: class Workout : NSObject, Coding { var name: ...
davidmark's user avatar
3 votes
0 answers
81 views

[MyClass initWithCoder:]: unrecognized selector sent to instance - On iOS16

I am using the [NSKeyedUnarchiver unarchiveObjectWithData:result] methode for unarchiving NSData in my objective c bases app. NSMutableArray *array = (NSMutableArray *)[NSKeyedUnarchiver ...
Mohammed Abdul Basith's user avatar
-1 votes
1 answer
90 views

How to archive and unarchive an SKPhysicsBody array using UserDefaults since iOS 12.0

I can successfully archive and unarchive an array of SKPhysicsBody's using UserDefaults as below but the unarchive process has been deprecated. This is the warning message... 'unarchiveObject(with:)' ...
Guitarman4's user avatar
2 votes
1 answer
348 views

Decoding NSArchiver with NSKeyedUnarchiver

I have some old archives that are basically stored preferences created with NSArchiver. I want to be able to decode them with NSKeyedUnarchiver since the NSArchiver/NSUnarchiver are deprecated in ...
Trygve's user avatar
  • 1,387

15 30 50 per page
1
2 3 4 5
14