Hey all!
What I'm trying to do is convert an EKEvent into NSData, and then convert it back into an EKEvent.
I looked around and noticed that in order to use NSKeyedArchiver, the class must conform to the NSCoding protocol. I also found that if I was creating a custom class, I could make it conform to the NSCoding protocol by implementi...
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...
My issue is then i retrive my NSArray of Store objects, all my NSString properties are giving me BadAccess errors. The int and double works fine!
store.h
@interface Store : NSObject<NSCoding> {
NSString *Name;
NSString *Address;
NSString *Phone;
double GeoLong;
double GeoLat;
int ID;
}
@property (nona...
When I try to get a h file that inherits from UITableViewController to conform to NSCoding, I can't switch views.
- (id) initWithCoder:(NSCoder*) coder
{
[self init];
return self;
}
Inserting the above code into the m file is what causes the problem. Why is that?
...
So far I have the following:
- (id)initWithCoder:(NSCoder*) coder
{
self = [super initWithCoder: coder];
if (self) {
// Call a setup method
}
return self;
}
Am I supposed to put the code to load the array in here? What could should I put and where should I put it?
...
[[NSUserDefaults standardUserDefaults] setObject:myArray forKey:@"myArray"];
If I make an array of custom objects conform to the NSCoding protocol, then does the above work? Do I have to make both the custom class and the view controller that holds the array of custom objects conform to the NSCoding protocol or just the custom class? D...
How do you use NSCoding to code (and decode) an array of of ten values of primitive type int? Encode each integer individually (in a for-loop). But what if my array held one million integers? Is there a more satisfying alternative to using a for-loop here?
Edit (after first answer): And decode? (@Justin: I'll then tick your answer.)
...
Hi - I've created an object called 'DateTracker' which conforms to NSCoding, so it contains encodeWithCoder and initWithCoder methods. When I initialise it, I call the following:
DateTracker *currentTracker = [[DateTracker alloc] initFromFile];
The initFromFile method looks like this:
- (id)initFromFile {
NSString *filePath = [s...
I can't seem to get NSCoding to store the 'frame' or 'center' properties of my UIImageView subclassed object. It seems to store everything else, both custom properties and standard class properties (e.g. 'hidden', etc...), but not the 'frame' or 'center' properties. I'm NOT trying to archive a UIImage (as this does not comply with NSCo...
I want to add the archiving (NSCoding) protocol to my model class, and then i implement both methods encodeWithCoder:(NSCoder*)coder and initWithCoder:(NSCoder*)coder. MyModelClass has 2 instance variables (NSString and NSImage), so i use the encodeObject:(id)object forKey:(NSString*)string method to encode the object plus the value for ...
I was able to save an NSMutableArray of custom objects to NSUserDefaults by implementing NSCoding in the custom class. However, now I want to save an NSMutableArray of these arrays. The compiler complains when I try to do this. How can this be done?
...
I have objects containing Quartz-2D references (describing colors, fill patterns, gradients and shadows) in Cocoa. I would like to implement the NSCoding protocol in my objects and thus need to serialize those opaque Quartz-2D structures.
Possible solutions might be:
Define a set of properties in my objects that allow to setup the dat...
I am having trouble loading from saved data an instance of a custom class that conforms to the NSCoding protocol. My class has a UIImage property and when I assign a new UIImage to it the program crashes with an exc_bad_access.
In the view controller I declare my object like so:
@interface SomeViewController : UIViewController {
...