views:

213

answers:

2

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 using any of the NSCoding methods such as NSKeyedArchiving encodeWithCoder ...

Using them returns this... NSInvalidArgumentException ...encodeWithCoder:] unrecognised selector sent to instance...

Is there any other way I can store this object for later use Thank you

p.s The class is a UIEvent

+2  A: 

Can you subclass the class and implement the NSCoding protocol in the subclass?

Jaanus
Thank you but the class has many internal members that do not support NSCoding either and the class cannot be subclassed
Noah
A: 

Depending on what the object has as members, you could create a dictionary, and set each member's value as a key in the dictionary and then write that to file.

However, I don't understand why you can't subclass the object and implement the NSCoding protocol, as Jaanus suggested?

Jasarien
The members do not support NSCoding and the I cannot subclass the class, I was wondering if there were some relatively low level C function to copy it from memory or something like that?? I cannot access some of the objects properties as they are private
Noah
Is there anyway to do this without NSCoding at all
Noah
**WHY** can't you subclass the class? What is preventing that?
Jasarien