tags:

views:

191

answers:

2

Hi

I have created a subclass of UIImageView and I am handling the touches for its objects inside the subclass itself.

Now when the user is about to exit the app I want to save the state of the images. And as there are multiple transforms which might have taken place on the images (I am saving all the transforms in a dictionary), I want to be able to save these objects in applicationWillTerminate.

I am using the encodeWithCoder and initWithCoder methods. The objects are saved and loaded as expected (at least looks like it). But when I print the frame size and origin, I get some absurd values on the console.

Can someone please tell me if the frame is not saved when encodeWithCoder is called and the contents are stored in a file?

Thanks.

A: 

Why don't you serialize the UIImageView's frame along with the actual UIImageView? Just add another property in encodeWithCoder and initWithCoder for the frame. This way, you can be sure to have the correct frame if you feel something is off.

Please paste the code where you are logging the values of the UIImageView's frame. I believe you may be casting to the wrong type which will cause your values to be off.

Dylan Copeland
Thanks. That is what I did. But still don't know why the frame won't get saved!
lostInTransit
A: 

write Dictionary content to plist by using NSUserDefault's object for key , and setobject for key method