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.
Questions tagged [nscoder]
189 questions
1
vote
1 answer
Coding array with NSCoder Swift
I'm trying to implement the NSCoder, but am currently facing a stubborn issue.
My goal is to save the array of strings via NSCoder to a local file and load it when the app opens next time.
Here is the class i've created, but i'm not sure how i…

David Robertson
- 1,561
- 4
- 19
- 41
1
vote
1 answer
I want to have two versions of encodeWithCoder in the same class
Let's say I have an object Person.
(I know that Person has syntax errors. Please ignore those.)
class Person: NSObject, NSCoding {
var name : String
var salary: NSNumber
// MARK: NSCoding
required convenience init(coder decoder:…

Four
- 406
- 4
- 13
1
vote
2 answers
iOS - Locally saving an array of key value pairs
In an app I'm developing the user needs to add an "enterprise" to use the app. However, they can add more than one "enterprise" to the app. Every enterprise added needs two things: a name, and an enterprise API key.
I have created an "Enterprise"…

matcartmill
- 1,573
- 2
- 19
- 38
1
vote
2 answers
Get property from NSCoder in required init(coder aDecoder: NSCoder)
I am implementing a Circle class (subclass of UIView) in Swift that sets its radius in its initializer according to the frame that is passed in init(frame: CGRect) like so:
override init(frame: CGRect)
{
radius = frame.width/2.0
…

nburk
- 22,409
- 18
- 87
- 132
1
vote
1 answer
EXC_ARM_DA_ALIGN exception while draw a dashed line using Bezierpath in iOS7
I am using Bezier path object to draw line and dashed line.
I saved those paths in a file and used NScoder to persist those path
Its working fine in iOS 6 device and iOS 7 simulator but throwing EXC_ARM_DA_ALIGN error in iOS 7 device for dashed Line…

meera
- 53
- 2
- 9
1
vote
1 answer
How does initWithCoder work in combination with Interface Builder?
I have a subclass from UITextField that I use in Interface Builder to build my view (so I set the class of this object to MyCustomTextField in directly in Interface Builder).
Now, I understood that when the view gets loaded, the initWithCoder:…

nburk
- 22,409
- 18
- 87
- 132
1
vote
2 answers
iOS 7 SpriteKit Game - error saving loading game: 'Attempted to add nil node to parent: name:'(null)'
I'm creating a unscramble words game.
I've reached the stage where I can save/load the game using:
(void)encodeWithCoder:(NSCoder *)aCoder
(instancetype)initWithCoder:(NSCoder *)aDecoder
When I save / load the game the first time there's no…
user3184425
1
vote
1 answer
App resumed from Background, nil property of NSManagedObject
Conditions
Getting a notification (txt message)
or Opening/Closing Notification Center
or Switch to another app, come back
Basically, the app comes back from background for a short period.
Issue
Layout is ok, but some of my properties that I get…

Séraphin Hochart
- 193
- 4
- 14
1
vote
1 answer
Using NSCoder to save custom MKOverlay
I have a custom NSObject class Trails that I want to save to a plist. I have it correctly saving and loading now, with the exception of one part. I have a custom MKOverlay class object Crumbs in that class that I want to save as well. No error is…

Glen
- 13
- 3
1
vote
1 answer
How to Use NSCoder with Versioned Classes
I'm having a bit of a struggle with NSKeyedArchiver and NSKeyedUnarchiver when the properties of the object change between the archive and unarchive process. Here's a concrete example:
I have a class, let's say Task, and it has the attributes name…

Steve Ross
- 4,134
- 1
- 28
- 40
1
vote
1 answer
Saving colors using NSCoder?
How do you save (by which I mean encode and decode) colors such as ccc3, ccc4, etc using NSCoder?
It doesn't seem to be supported. The only way I've been able to solve it is to save ints, and then when I need the colors I generate them from the…

zardon
- 2,910
- 6
- 37
- 58
1
vote
1 answer
iOS: Archiving NSMutableArray
I've Googled and searched SO for this with no straightforward results. It seems I have a fundamental misunderstanding of the following from Apple's documentation:
An archive can store an arbitrarily complex object graph. The archive
preserves the…

Steve Ross
- 4,134
- 1
- 28
- 40
1
vote
1 answer
How to encode a unichar array using NSCoding
My custom object contains an array of unichar primitives. However there is no encodeUnichar:ForKey method in NSCoder. My solution is to transform my 2d unichar array into an NSString and then encode that.
However, the absence of a method to encode…

Tangler
- 168
- 9
1
vote
1 answer
Saving data encoded with NSCoder
I'm encoding some NSDictionary with NSCoder and I want to save it somehow inside the app. Could anyone please tell me how I could do it?
I want to give the user the ability to see what he's done previously when he opens the app.

Sorin Cioban
- 2,237
- 6
- 30
- 36
0
votes
3 answers
opinions needed for saving data
I'm creating an app that needs to save arrays. For test purposes I'm currently using a property list file. I was looking at the other methods of storing long term data. Core data and NSCoder seems promising.
I`m saving very simple pieces of data,…

user1053078
- 153
- 2
- 5