Questions tagged [nskeyedarchiver]

NSKeyedArchiver, a concrete subclass of NSCoder, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyedArchiver’s companion class, NSKeyedUnarchiver, decodes the data in an archive and creates a set of objects equivalent to the original set.

NSKeyedArchiver, a concrete subclass of NSCoder, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyedArchiver’s companion class, NSKeyedUnarchiver, decodes the data in an archive and creates a set of objects equivalent to the original set.

A keyed archive differs from a non-keyed archive in that all the objects and values encoded into the archive are given names, or keys. When decoding a non-keyed archive, values have to be decoded in the same order in which they were encoded. When decoding a keyed archive, because values are requested by name, values can be decoded out of sequence or not at all. Keyed archives, therefore, provide better support for forward and backward compatibility.

Click Here for class reference

554 questions
-1
votes
1 answer

Swift: Unknown error - Unexpectedly found nil while unwrapping an Optional value

I know this is a common error people post here but I can't find a post that matches to what I'm doing even if its the same fundamentally. I'm new to Swift and just trying to find my way, thank you. The first time I open my app, a blog reader app…
WokerHead
  • 841
  • 1
  • 14
  • 37
-1
votes
2 answers

Swift: Error - Initializer for conditional binding must have Optional type, not 'Void' (aka '()')

Using Swift 3, blog reader app reading from a MYSQL database using JSON and PHP. User has the ability to save the blog they want to keep getting updates from using a follow button (as well as unfollow button). Instead of saving the entire array,…
WokerHead
  • 841
  • 1
  • 14
  • 37
-1
votes
2 answers

How to save data to NSUserDefaults in Swift 3?

I want to save my data into NSUSerDefaults in Swift3 in: func a() { let userDefaults = UserDefaults.standard let sessionData = NSKeyedArchiver.archivedData(withRootObject: session) userDefaults.set(session, forKey: "SpotifySession") …
Doe
  • 351
  • 1
  • 7
  • 14
-1
votes
1 answer

How to save a custom object to NSUserDefault which contains UIImage and NSMutableArray?

In my project I need to save a custom object(Person) which have an UIImage, NSMutableArray and NSString objects. Currently I am able to encode and decode the NSString objects and archive Person to in NSUserDefault. Everything works fine except for…
Rokon
  • 326
  • 2
  • 10
-1
votes
1 answer

Archiving, unarchiving and cleaning objects in cache with Swift

I have problems in handling the persistence of some classes in the cache. This is the code I tried and that does not work at all either recovering the archived data or deleting it: func cacheDirectoryURL()->NSURL?{ let…
-1
votes
4 answers

NSUserDefaults is saving just last value

I have a problem if anyone can help me or can give me an advice whose who faced with similar problem. Ok, I save data in NSUsersDefaults like this NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *data = [NSKeyedArchiver…
-1
votes
1 answer

Cannot Archive Array of Values Representing CGPoints

I have converted CGPoint To NSValue and put all the resulting values in q NSArray but when I use [NSKeyedArchiver archiveRootObject:ArrayName toFile:PointArrayFile]; it gives me error. So what's the problem?
-1
votes
2 answers

How do i serialize/deserialize GTLDriveFile Object into pList

I'm using google drive files in my application. Accessing files, downloading files, uploading files are working as a charm. Now I'm trying to save the GTLDriveFile information on local(pList) by using NSCoding. Can you please help me to save this…
iTag
  • 398
  • 2
  • 19
-1
votes
1 answer

How to use JSONKit to transmit data to a server in Xcode?

I'm basically trying to send data to a server that contains objects and fellow peers have told me to use JSONKit. As of now, I've implemented NSCoding protocol and serialized my objects with NSKeyedArchiver. But I can't find any resources on how to…
-2
votes
1 answer

Is it a time-consuming operation for archiving and unarchiving?

When we archive a object use archiveRootObject . Is it a time-consuming operation for archiving and unarchiving? [NSKeyedArchiver archiveRootObject:xxx toFile:filePath]; In a thread . dispatch_async(dispatch_get_global_queue(0, 0), ^{ …
user9067376
-2
votes
1 answer

NSUserDefaults encodeWithCoder unrecognized selector sent to instance

I want to save NSMutableDictionary to NSUserDefaults then get error: NSUserDefaults encodeWithCoder unrecognized selector sent to instance. Fatal Exception: NSInvalidArgumentException [NSUserDefaults encodeWithCoder:]: unrecognized selector…
Vijay Masal
  • 200
  • 11
-2
votes
1 answer

Assigning unarchived object to a different object works, why/how?

Assigning an archived dictionary object but unarchived and assigned to an array does not seem to produce an exception and the logged out data from the array is that of the dictionary and not in array format at all if it was possible to assign to a…
-2
votes
1 answer

Archieve the UIVIew and its subviews using nscoding

How to archive UIView and its subviews using NSCoding protocol and NSKeyedAchiever? I have seen many examples for archiving NSObject class object but i am not able to archive the UIView and its subviews and their properties and state. Can any body…
Prerna chavan
  • 2,899
  • 7
  • 32
  • 76
-3
votes
1 answer

Check if NSKeyedUnarchiver is returning nil

I need to do an if statement that is based on weather a variable has been archived. I do this as follows: if NSKeyedUnarchiver.unarchiveObjectWithData(encodedNotif) == nil { } But if 'encodedNotif' is nil I get an: fatal error: unexpectedly found…
1 2 3
36
37