I'd like to save an NSMutableDictionary object in NSUserDefaults. The key type in NSMutableDictionary is NSString, the value type is NSArray, which contains a list of object which implements NSCoding. Per document, NSString and NSArray both are conform to NSCoding.
I am getting error :
-[NSUserDefaults setObject:forKey:]: Attempt to i...
My aim: to continue a web session across an app interruption (eg. incoming SMS that is read).
Approach A:
I have tried to store the contents of a UIWebView in NSUserDefaults, like this:
NSData *webViewData = [NSKeyedArchiver archivedDataWithRootObject:webView];
[[NSUserDefaults standardUserDefaults] setObject:webViewData forKey:kDefaul...
Version 1.0 of an application has a data model, which is saved/loaded using the NSKeyed(Un)Archiver classes, as all model classes adhere to the NSCoding protocol. Say the following hierarchy exists:
-> Houses (NSMutableArray)
-> -> House (Custom Object)
-> -> -> Color (3 ints, RGB)
-> -> -> Number of Residents (int)
Say that there are...
Ideally an NSCoding compliant class will work as expected using encodeWithCoder: and initWithCoder: (at least I thought so till recently) without the developer having to bother about what goes on inside the routines (unless my idea of an NSCoding compliant class are totally screwed up!)
The UIImageView class is NSCoding compliant. So I ...
Malloc like this
int **terrain;
terrain = malloc(sizeof(int*) * mapSize.x);
for (int i = 0; i < mapSize.x; i++) {
terrain[i] = malloc(mapSize.y * sizeof(int));
}
Use it.
Convert to NSdata like this before saving
NSData *data=[NSData dataWithBytes:terrain length:(30*sizeof(int*) +30*30*sizeof(int) )];
[rootObject setValue:data ...
My dilemma is as follows:
I have a custom subclass of UIImage (I've added some serialization methods i.e. initWithCoder, encodeWithCoder), and I would like to apply my custom subclass as a variable to a UIImageView, or at least a subclass of UIImageView.
As you are aware, UIImageView has a variable called "image", that is of type UII...
Is it possible to encode CGPathRef variables? I mean is there an encodeObject:forKey like method for CGPathRef variables?
...
When I fill in the encodeWithCoder: for objective c classes for an iPhone app will it make make the archive file larger if I use long keys as opposed to short keys for all of my variables?
For example if I use really long keys like this:
[coder encodeBool:myBoolean forKey:@"My_Excesively_Long_Boolean_Key"];
will it make the archive f...
I've implemented an save on applicationWillTerminate and load on applicationWillFinishLoading.
There is a complete object tree, all implement the NSCoding protocol and I've check the types I enter.
One of the classes also stores an NSMutableData to the NSKeyedArchive, which I suspect might break unarchiving occasionally. Weirdly enough,...
Is it possible to encode an objective-c block with an NSKeyedArchiver?
I dont think a Block object is NSCoding compliant, therefore [coder encodeObject:block forKey:@"block"] does not work?
Any ideas?
...
I have made an class which conforms to the NSCoding protocol and does all the encode and decode stuff.
For my app, I simply want to persist an object from that class to the device and the next time when the app launches, I want to load that object back into memory.
Basically it's just an class which holds some user input information. F...
Given: An application that accesses a directory of files: some plain text, some binary files that adhere to a particular NSCoding implementation, and perhaps other binary files it simply doesn't understand how to process.
I want to: Be able to figure out which of the files in that directory adhere to my NSCoding class, and I'd prefer no...
Hi,
I am using an Objective c class, a subclass of NSObject.
This class cannot be modified. I have an instance of this class that I wish to write to a file which can be retrieved and later reinstate. The object does not conform to NSCoding.
To sum up, I need to save an instance of a class to a file which can be retrieved later, without ...
I have an object myObj, which is an instance of a class MyClass. Some of its instance variables always have their initial values passed in by the calling code. Other instance variables will be initialized in one of two ways. For an instanceArray of type NSMutableArray, the possibilities are either
instanceArray = [[NSMutableArray all...
Is there a better way to serialize an ObjC object than using /NSKeyedArchive?
I need to distribute the object through a C++ std:ostream-like object to put on another computer.
The object has over 122 members of various types... for which wants me to
[coder encodeObject: (id) forKey: @"blah"];
for all of them...
Does anyone have a...
I have a custom class that is used as a wrapper to an NSMutableArray
@interface AllCourses : NSObject {
NSMutableArray *arrClasses;
}
The array above stores Objects of another custom class.
@interface Course : NSObject {
NSString *className;
NSString *classGrade;
NSInteger creditHours;
}
I use the method below to add Course obje...
Hi everybody,
I've a problem with Iphone programming... I've a NSMutableArray containing object of type "MyClass". MyClass has some parameters, like NSNumber and NSString.
I've followed the Apple Tutorial about coding and decoding object using NSCoding, but when I try to decode the file I've stored, the NSMutableArray contain object of...
Hi all! I have an object which conforms to the NSCoding protocol.
The object contains a method to save itself to memory, like so:
- (void)saveToFile {
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:self forKey:kData...
EDIT: I seem to have found something that's helped. I retained the ivar "stack" and now it seems to be working
I have been serializing several custom NSObject classes without issue. Now I'd like to serialize my NavigationController stack. Each viewController only needs a couple of properties saved in order to rebuild the navigation ...
I have a need to archive an array of objects of several different types. Each object has its own instance vars.
Is it better to create singleton object with an array that holds ~20 archived objects, or have a single archived object that has an array of all the other objects? Sorry if that's confusing, but I'm a bit confused myself.
...