Re: iOS: encoding a custom view with a shape in it
Re: iOS: encoding a custom view with a shape in it
- Subject: Re: iOS: encoding a custom view with a shape in it
- From: Steve Christensen <email@hidden>
- Date: Wed, 15 Jun 2011 15:28:21 -0700
On Jun 15, 2011, at 8:29 AM, Development wrote:
> Using the keyed archiver I save all of the values related to the drawing inside of the view. Then of course I save the view's parameters.
OK, I can see archiving the properties of the shape(s) so that you can restore them. It sounds like you're trying to archive the view as well, but I'm unsure why. A view just provides a place to draw things, but it has nothing to do with the data model, so it doesn't really make sense to save it as well. The properties needed to draw the shapes should be able to stand independent of the view.
> I'm not sure what you mean by the objects it draws? I'm using CGContext methods to draw rectangles and elipses so other than saving all the values such as transforms and colors and all I'm not sure what you mean.
The objects are the rectangles and ellipses. I had assumed that you created shape classes to hold the properties (frame, rotation, color, etc.) and to draw those shapes.
> On Jun 11, 2011, at 6:49 PM, Steve Christensen wrote:
>
>> And also to clarify, are you "freeze drying" a view or the objects it draws? You should be doing the latter since that's part of your model.
>>
>>
>> On Jun 11, 2011, at 6:47 PM, Steve Christensen wrote:
>>
>>> How do the results differ between what you saw before and after saving the document? Is everything wrong? or just the scaling, the rotation, what?
>>>
>>> And to draw an object, are you using an affine transform just to rotate it or for scaling and/or translation as well?
>>>
>>>
>>> On Jun 9, 2011, at 4:25 PM, Development wrote:
>>>
>>>> This app allows users to do a number of graphical things. On of those things is to draw rectangles and ellipses.
>>>>
>>>> No it would not be complete if they could not resize and rotate these shapes. Thus the features exist.
>>>>
>>>> The problem comes when I freeze dry the object.
>>>> I encode it exactly as it exists at the moment the saveDocument: option is invoked.
>>>> colors, frame,rotation etc
>>>> logging these values confirms them
>>>>
>>>> When I unfreeze it, well the values remain identical. hence I know the save worked.
>>>>
>>>> I initialize the object with the decoded rectangle for the frame
>>>> I then apply the transition to rotate it to the correct angle.
>>>>
>>>> hmm the result looks nothing like the initial item did at save time
>>>>
>>>> So I've been looking at this very closely... Is this happening because simply applying the last known frame and angle does not mean it will match?
>>>> If this is the case, does it mean then that in order to preserve the exact state, I must not only save all the data about the object but an array of every change made to the object such as resizes and rotations in order to get the correct result?
>>>>
>>>> My bandaid is to convert the view in to a UIImage and save the image. This "fixes" the problem however the downside is that special effects that can be applied to rectangles and ellipses are not available on reload.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden