Questions tagged [nscoding]

NSCoding is a protocol from Apple Foundation framework. The NSCoding protocol declares the two methods that a class must implement so that instances of that class can be encoded and decoded.

The NSCoding protocol declares the two methods that a class must implement so that instances of that class can be encoded and decoded. This capability provides the basis for archiving (where objects and other structures are stored on disk) and distribution (where objects are copied to different address spaces).

These two methods in the NSCoding protocol are:

  • encodeWithCoder: Encodes the receiver using a given archiver. (required)
    -(void)encodeWithCoder:(NSCoder *)encoder

  • initWithCoder: Returns an object initialized from data in a given unarchiver. (required)
    - (id)initWithCoder:(NSCoder *)decoder

And in Swift :

  • init(coder decoder: NSCoder!)

  • func encodeWithCoder(_ encoder: NSCoder!)

604 questions
-2
votes
3 answers

Sorted Array/Map Swift

I performed a GET request, and I saved data inside data like this if let data: [MyMap] = response?.results { let var_to_sort = data self.generateStuff(var: var_to_sort) } MyMap is a mappable object defined like this: class MyMap: NSCoding { …
ConteOlaf
  • 75
  • 2
  • 8
-2
votes
1 answer

"NSCoding is not supported" when trying to use KWStepper custom UI stepper pod

I am using a custom stepper called KWSepper, found on GitHub. I have used the protocol in my table view cell file. When trying to access the table view in a VC I get a fatal error on this line of code from the authored KWStepper swift file: …
Matteo
  • 47
  • 9
-2
votes
2 answers

Is NSCoding equal to "Compress file" on Mac?

I am using NSCoding and NSArchiver to persist my iOS App Data. But I want to know if it is equivalent to using zip / unzip software? If not, how does it work?
user8637708
  • 3,303
  • 2
  • 13
  • 15
-4
votes
1 answer

How to create a Swift model for JSON

{"dataList":{"1547795650562": { "c0a8007b-6759-111d-8167-59e8dabe0086": { "recordDate": 1547795650562, "resultValue": "160", "vitalParameter": { "uom": { "code": "KG", …
mrafi5
  • 35
  • 8
1 2 3
40
41