nscoding Questions

2

Solved

When I create a subclass of UIView or UIViewController with a stored property, Xcode will not compile my project unless I include an implementation of required init?(coder aDecoder: NSCoder). Curre...
Tubulate asked 8/9, 2018 at 21:28

2

Solved

In testing how the new Codable interacts with NSCoding I have put together a playground test involving an NSCoding using Class that contains a Codable structure. To whit struct Unward: Codable { ...
Secessionist asked 7/6, 2018 at 16:57

3

I am having trouble with adopting NSSecureCoding. I encode an array containing objects of my custom class, which adopts NSSecureCoding properly. When I decode it, passing the class NSArray (which i...
Plebeian asked 24/6, 2014 at 0:49

4

Solved

i spent all afternoon banging my head against the wall trying to figure out why decoding of this class was failing. the class has a property that is an NSArray of Foo objects. Foo conforms to NSSec...
Typewritten asked 25/10, 2013 at 0:32

3

Solved

I am going to try and use the new testing features in Xcode 7 (code coverage) and Swift 2.0. Using code coverage, I see that I am not testing my NSCoding methods. For a trivial example of saving a...
Heteronym asked 15/8, 2015 at 23:34

10

Solved

Does anyone know how to fix this error with Xcode 9 GM? I'm working on an app made with Xcode 8.3, the deployment target is for iOS 9.3 and I never had this problem before. I don't find any informa...
Seagraves asked 14/9, 2017 at 14:20

6

Solved

I have a simple object which conforms to the NSCoding protocol. import Foundation class JobCategory: NSObject, NSCoding { var id: Int var name: String var URLString: String init(id: Int, nam...
Sero asked 28/12, 2016 at 4:38

2

I have a small app that has a few saving functionalities. I have a data model class called: Closet: class Department: NSObject, NSCoding { var deptName = "" var managerName = "" var Task: [Ass...
Suttles asked 16/8, 2015 at 6:13

4

I got the following codes on writing an object named Packet and send to the other side through Multipeer connectivity. However, I got the following error whenever it try to decode the encoded objec...

5

Solved

I have this in Playground using Swift 3, Xcode 8.0: import Foundation class Person: NSObject, NSCoding { var name: String var age: Int init(name: String, age: Int) { self.name = name self.age ...
Sexology asked 23/6, 2016 at 0:37

12

Solved

I am currently trying to save a custom Swift class to NSUserDefaults. Here is the code from my Playground: import Foundation class Blog : NSObject, NSCoding { var blogName: String? override i...
Stavros asked 20/10, 2014 at 15:33

2

Solved

I'm trying to retrieve an array of custom object in Swift, where i get the error "UserInfo={NSDebugDescription=value for key 'root' was of unexpected class 'NSArray'. Allowed classes are '{(Music...
Gaussmeter asked 20/5, 2019 at 8:42

4

I have added category methods to NSUserDefaults to store and retrieve encoded objects (in this case, an NSArray). I am having a problem retrieving the encoded data. Here is my code: - (void)encode...
Methedrine asked 21/9, 2018 at 12:20

4

I have a class and inside the class is a (swift) array, based on a global struct. I want to save an array with this class to NSUserDefaults. This is my code: struct mystruct { var start : NSDate ...
Coccidiosis asked 28/8, 2014 at 10:36

5

Solved

I have an iOS 7 application that saves a custom object to app's iCloud Docs folder as a file. For this, I make use of NSCoding protocol. @interface Person : NSObject <NSCoding> @property (...
Ester asked 25/8, 2014 at 18:27

2

Solved

Is it possible to store a tuple using NSCoding? I have a tuple like ((UInt8, UInt8), (UInt8, UInt8)). But aCoder.encodeObject(myTuple) doesn't work. Do I have to convert the tuple into NSData or is...
Everhart asked 8/3, 2015 at 17:58

4

Solved

I get the error "Type 'Ship' has no subscript members when I try to do: var coor = ship[index] I tried to do var coor = ship?[index] as? Coordinate But I get this error: "Cannot use optional ...
Birdwatcher asked 21/3, 2016 at 17:44

1

Solved

I have the following struct… struct Photo: Codable { let hasShadow: Bool let image: UIImage? enum CodingKeys: String, CodingKey { case `self`, hasShadow, image } init(hasShadow: Bool, ima...
Aim asked 26/7, 2017 at 8:53

0

I'm getting these crash reports from XCode (I pasted one at the bottom) and I can't reproduce the error or figure out what the problem is. From the backtrace I'm thinking it could be related to th...
Thielen asked 30/3, 2017 at 5:12

4

Solved

I've been searching for an article that explains NSCoding (NSKeyedArchiver...) advantages and disadvantages over use of CoreData (SQLite....). There's a lot of options, I can implement my own cus...
Hoosegow asked 5/3, 2012 at 15:40

3

Solved

I am trying to use the NSCoding protocol on a class I have written in swift, but cannot seem to figure out why the compiler complains that it "does not conform to protocol NSCoding" when I do imple...
Glassy asked 9/9, 2014 at 16:54

4

Solved

I am trying to encode annotations that are on a map, but I read that I am not able to encode CLLocationcoordinate2D variables. Does anyone know how I can solve this? Here is some code. This is whe...
Cajole asked 10/1, 2013 at 22:54

3

Solved

I would like to implement init(coder aDecoder: NSCoder!) in a superclass, and use it in all subclasses by calling a class method on the particular subclass in the superclass at runtime. MySuperCl...
Crosswalk asked 12/7, 2014 at 9:20

3

I am blocking into something and I am sure it is too big. I have a custom object that look like this @interface DownloadObject : NSObject <NSCoding>{ NSNumber *key; NSString *name; NS...
Gile asked 4/7, 2011 at 8:51

1

Solved

I have seen several questions similar to mine; however, those are pertaining to swift 2/1 and I am currently using swift 3. I believe Apple has changed it slightly. class Person: NSObject, NSCodin...
Sallie asked 20/6, 2016 at 14:31

© 2022 - 2024 — McMap. All rights reserved.