nscoder

Sample (preferably simple) subclass of NSCoder?

I'm trying to create a subclass of NSCoder, but I really don't know where to start. Apple's documentation lists which methods are required, but not much else. Maybe my Google-fu is weak, but I can't find any examples of an implementation of, e.g. encodeValueOfObjCType:at:, anywhere. (Though I assume it involves a lot of cases.) Anyone k...

iphone / objective C / how to encode a double[] for archiving

I am using double[] instead of NSArray. Would anyone know how to encode it for archiving ...

Trouble decoding with NSKeyedUnarchiver

Hi, I am writing an app targeted at iOS 4.0 on XCode 3.2.3 where I store some data when the app closes using NSCoder protocol. Saving seems to work fine, the problem is retrieving the data from the saved files. My save method looks like this: -(void)saveMusicalWorksToMemory{ // create the save paths NSArray *paths = NSSearchPat...

Is NSMutableArray writeToFile recursive?

Does NSMutableArray support recursive serialization? E.g. will a NSMutableArray of NSMutableArray's serialize the entirety of the heirarchy out when calling writeToFile? Example: NSMutableArray *topArray = [[NSMutableArray alloc] init]; NSMutableArray *bottomArray = [[NSMutableArray alloc] init]; NSString *foo = @"foo"; NSString *bar...

Problems with the NSKeyedArchiver

Hi, i've still have got problems with the NSKeyedArchiver. I implemented everything I was told to do, but it still does not work. I'm kind of frustrated. So could anyone help me out? Here is the .h file: #import <Foundation/Foundation.h> #import "JFIdentifier.h" // This is my own class to create a unique identifier for every JKDataObj...

When does encodeWithCoder get called?

This will save an array (I think). - (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeObject:myArray forKey:@"myArray"]; } Do I have to directly call this method when I want to save an array or do I have to do something else? ...

When does initWithCoder get called?

This will load an array - (id)initWithCoder:(NSCoder*) coder { self = [super initWithCoder: coder]; if (self) { myArray=[coder decodeObjectForKey:@"myArray"]; } return self; } What is the code that will call this function so that the array can be loaded? ...

Does this write or read an array?

[[NSUserDefaults standardUserDefaults] setObject:myArray forKey:@"myArray"]; I'm trying to figure out how to save and load an array using NSUser Defaults. I already have the NSCoding delegate methods defined, just need to know the actual commands to execute that will call those methods. ...

Objective C - How do I use initWithCoder method?

I have the following method for my class which suppose to load the nib file and instantiate the object. - (id)initWithCoder:(NSCoder*)aDecoder { if(self = [super initWithCoder:aDecoder]) { // Do something } return self; } so based on this init method how do u instantiate an object of this class? The init method...

NSCoder and custom types

How do you use NSCoder to encode and decode custom types? For example, how would you use NSCoder with an instance of "STATE" where: typedef enum { ON, OFF } STATE; ...