Questions tagged [nscoder]

The NSCoder abstract class declares the interface used by concrete subclasses to transfer objects and other Objective-C/Swift data items between memory and some other format.

189 questions
1
vote
1 answer

How to save a CapturedRoom using NSCoder

I'm trying to build an app that creates a floor plan of a room. I used ARWorldMap with ARPlaneAnchors for this but I recently discovered the Beta version of the RoomPlan API, which seems to lead to far better results. However, I used te be able to…
Dennis
  • 53
  • 4
1
vote
0 answers

'Failed to call designated initializer on NSManagedObject class' NSManagedObject and NSCoding

I'm attempting to: Load an array of custom objects from JSON file. Save it in CoreData. Fetch it using NSFetchRequest. Note: Each element in the array of custom objects named 'Cube' also contains a nested array of custom objects named 'Algorithm',…
thatGuyNeil
  • 55
  • 2
  • 6
1
vote
0 answers

coder.decodeDouble causing crashes on app updates, value was previously an optional

I have an object that stores latitude and longitude coordinates. At one point, they were stored as an Optional Double?. I have since changed so it is a non optional Double. Now I see random crash logs from what I assume is users updating their…
Hbombre
  • 111
  • 1
  • 7
1
vote
2 answers

What is the correct way to unarchive something that was archived using encodeRootObject:?

I am attempting to use the Keyed Archiver classes for the first time and I'm failing the last assert in this simple test (OCUnit): - (void) testNSCoding { NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:5]; [dict…
Chris Hill
  • 1,914
  • 1
  • 16
  • 24
1
vote
0 answers

ColorWell for Colored "Category"

I have an NSTextField, an NSTableView with a column "category", an NSColorWell, and a custom array controller. The NSTextField and the column "category" from the NSTextField are bound to the array controller so that everything I write in the text…
dehlen
  • 7,325
  • 4
  • 43
  • 71
1
vote
1 answer

Round-trip encoding and decoding with NSKeyedArchiver and NSKeyedUnarchiver

In the process of implementing init(coder:) for a custom NSView subclass, I came across some strange behavior with NSKeyedArchiver and NSKeyedUnarchiver that I still don't entirely understand. Consider this sample code: let label =…
Chris Frederick
  • 5,482
  • 3
  • 36
  • 44
1
vote
0 answers

Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'

My iOS application is working fine in iOS 10 and newer version. But when I was trying to run my app on iPad mini with iOS version 9.3.2 then Application is crashing. I am trying to push a view controller and I am using storyboard for all view…
ajeet sharma
  • 803
  • 10
  • 37
1
vote
1 answer

Pointers to existing objects after encodeWithCoder: and initWithCoder:

How does NSCoding deal with encoding and decoding of pointers to other objects rather than values? I have a range of model classes which I need to encode, and they need to reference each other with weak properties. I was surprised to find that the…
mashers
  • 1,009
  • 7
  • 22
1
vote
0 answers

Encoding & decoding custom Swift objects with recursive pointers

I'm trying to encode and decode an array of custom objects in swift. The objects look something like this: class MyObject : NSCoding { var name: String var otherObjects: [MyObject] init?(name: String) { self.name = name …
sjg1729
  • 11
  • 3
1
vote
1 answer

NSKeyedUnarchiver decodeObjectForKey crash after importing as a framework

Before pulling out MyClass into a framework, I could save instances of MyClass into Core Data just fine. Here's the implementation of MyClass: open class MyClass: NSObject, NSCoding { required public init?(coder aDecoder: NSCoder) { …
7ball
  • 2,183
  • 4
  • 26
  • 61
1
vote
2 answers

Swift 3 NSCoder unrecognized selector sent to instance

I am trying to save a list of a custom class to user defaults and I keep receiving the "unrecognized selector sent to instance" error when saving. I have no issues when getting the array from user defaults. This is the code I am using to save to…
Vlad Lund
  • 29
  • 5
1
vote
0 answers

Swift 3: NSCoder Crash (encodeWithCoder: unrecognized selector sent to instance)

The error that is crashing my app when I click the save button -[BlogApp.Blog encodeWithCoder:]: unrecognized selector sent to instance 0x7fbe31d33800 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:…
WokerHead
  • 947
  • 2
  • 15
  • 46
1
vote
1 answer

Encode nested enumeration swift 3

Purpose I have a User class with a status property and I want store it into NSUserDefault which need to encode the User class first. User class code updated version public class User: NSObject, NSCoding { override init() {} var status:…
Stephen Chen
  • 3,027
  • 2
  • 27
  • 39
1
vote
1 answer

NSCoder: Unrecognized selector sent to instance

So, I'm new to iOS and have been using online tutorials to learn the platform. The tutorials I'm using are building apps with iOS 9 while I'm using iOS 10. Because of that I have run into the title issue. Here is some code: CalendarEvent.swift class…
blutuu
  • 590
  • 1
  • 5
  • 20
1
vote
0 answers

Getting nil while unwrapping an optional value error - while saving enum value in Swift

I have the following event model: class Event: NSObject, NSCoding { var name: String var category: Category enum Category: String { case Call = "Call" case Coaching = "Coaching" } } When a user updates their selection of the…
robinyapockets
  • 363
  • 5
  • 21