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

570 questions
0
votes
1 answer

Can not Archive and Unarchive file to Document Folder

This code does not give any error but it's not creating the "plist" file nor reading from it. I wrote a code that specifies the direct path to the folder and it creates and writes to the file although it cannot read from it. [NSKeyedArchiver…
0
votes
1 answer

Why is my NSURLResponse leaking memory when archived?

I found a leak in my code where archiving and unarchiving an NSURLResponse was causing a leak, and I can't figure out why. - (void)doStuffWithResponse:(NSURLResponse *)response { NSMutableData *saveData = [[NSMutableData alloc] init]; …
user277461
0
votes
1 answer

Archiving Multiple Objects and Unarchiving them as array of objects in objective C

I am calling the function archiveQueue to store object of type MYJSON at various times through out the program, and now I want to restore everything that I stored uptill now in an array. Following is the function that I am using to store the objects…
Nilesh Agrawal
  • 3,002
  • 10
  • 26
  • 54
0
votes
1 answer

Archive a NSMutableArray

I need to archive a NSMutableArray which is being controlled by an ArrayController. I tried this: [NSKeyedArchiver archivedDataWithRootObject:array]; But I got this error: *** -[NSKeyedArchiver dealloc]: warning: NSKeyedArchiver deallocated …
0
votes
1 answer

NSKeyedArchiver would not save or load objects

So I have an array with some custom classes: NSMutableArray With Games (FirstViewcontroller) -Game with Dices (Game.m) -- Dices With Options (Dices.m) In each custom class i've setter the encode and decode up: -(void)encodeWithCoder:(NSCoder…
Kets
  • 438
  • 2
  • 8
  • 24
0
votes
2 answers

Encoding Large Object Graph Using NSKeyedArchiver Eats Memory

I'm using a NSKeyedArchiver to encode a big object graph (76295 objects.) It takes a lot of time but even worse the NSKeyedArchiver doesn't give back all its memory. After using the Leak check, the code doesn't appear to leak at all but for some…
Ger Teunis
  • 945
  • 1
  • 14
  • 30
0
votes
2 answers

Implementing NSCoding protocol to send object over to the Java based server

I have asked a similar question a couple of days ago... While I have made some progress, I still cant seem to make it work. Here is what I got up till now: customWriteableObj.h: @interface customWriteableObj : NSObject @property…
Marci-man
  • 2,113
  • 3
  • 28
  • 76
0
votes
3 answers

How to archive an object in one View Controller and then unarchive it in another?

I have an object "School" with a mutable array property "favoritesArray" and an NSString property "name". I have 2 view controllers "HomeViewController" and "FavoritesTableViewController". In my HomeViewController when a button is tapped this…
0
votes
1 answer

Deleting Rows From Table View | NSUserDefaults + NSKeyedArchiver

- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; myFavsTwo = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:[[[NSUserDefaults standardUserDefaults] objectForKey:@"MyFavoritez"]…
Mou某
  • 556
  • 3
  • 10
  • 32
0
votes
2 answers

Animation of NSImage gets lost after archiving it with NSKeyedArchiver

Following situation: I have an instance of my NSObject sublcassed object. One of it's properties is a NSImage. After instanciating the object I convert it with NSKeyedArchiver to data, send it over the network, unarchive it with NSKeyedUnarchiver…
papr
  • 4,717
  • 5
  • 30
  • 38
0
votes
1 answer

Why does NSMutableArray Count crash my app?

I've ran into a problem. Everytime I'am starting my app it crashes. Heres me code. The Debugger Says: [list count] crashes the app. I have no idea. NSLog(@"%@", self.list); gives me one item as expected... if ([[NSFileManager defaultManager]…
danielreiser
  • 5,292
  • 5
  • 31
  • 43
0
votes
1 answer

How to store a CLLocation object using NSKeyedArchiver?

I am slightly confused why the following doesn't work. Can someone enlighten me? I have one function that returns a filePath: - (NSString *) lastLocationPersistenceFilePath { NSString *filePath = [[[NSBundle mainBundle] resourcePath]…
Florian
  • 579
  • 1
  • 10
  • 19
0
votes
1 answer

NSKeyedArchiver Doesn't Seem Properly Save an MPMediaItemCollection Object

I am trying to save a playlist of songs created with the media picker. I tried to use the suggestion provided in Persist a MPMediaItemCollection Object Using NSUserDefaults. This solution uses NSKeyedArchiver as follows: NSData *data =…
0
votes
2 answers

Core Data saving array and dictionaries - best practices

Below is an illustration of the kind of data I want to save in Core data. Every city has many schools , every school has many grades and every grade has many students and their details. I have read a couple of things about Core data and have got it…
Sharanya K M
  • 1,805
  • 4
  • 23
  • 44
0
votes
0 answers

NSKeyedUnarchiver can't decode my string

I am trying to make a document-based application where it needs to decode the content using NSKeyedUnarchiver. However, it failed to extract the information even though there is indeed data containing! The following is my code, and also the…
donkey
  • 4,285
  • 7
  • 42
  • 68