-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to save drawing ? #65
Comments
I think the best way is to apply the protocol NSCoding to each tool, so you can serialize the arrays of steps and apply them again in the future |
Can you give an example on how to do this, I can't seem to figure out how to save a drawing. I'm using Realm as a database and I want to save the drawing in Realm so I can reload it, but I'm stuck at implementing the NSCoding protocol in the Pen tool. |
Try to look here to get some idea https://github.com/mro/MROGeometry/blob/master/MROGeometry/NSCoder_MROCGPath.m |
Still don't get how to do this. I've added the NSCoding protocol to the AceDrawingPenTool and tried to implement the example you gave. But I don't know when and where to call the encode feature to save it? Can you provide one example on one of the tools how to implement it please? |
If you have implemented the NSCoding protocol correctly, saving it should be very easy. Here is a tutorial |
Hi acerbetti, I finally had some time to pick up where I left. I've wrote this code to save the UIBezierPath (As i understand correctly the UIBezierPath adheres to the NSCoding protocol so I didn't add that (just testing to save and load the lines). I've made the pathArray of the AceDrawingView class public so I can access it in my other classes. This is my code as of now but it doesn't work at the moment I see that the data is saved in NSData structure but it's not loading the drawing back.. :
|
@Tripwire999 That is the same issue I'm having. I am correctly storing and reloading the drawn paths, but when I run the method |
@JinkProject
And the returned tool is added to the pathArray. After that I just call:
|
@Tripwire999 OK. Cool. Let me try that. Could this not be achieved the same why by just making |
@JinkProject It's because i'm using Realm and i'm not only storing the DrawPath stuff but also some other parts in Realm like lineAlpha, lineWidth, tooltype e.t.c. |
@Tripwire999 How did you encode/decode the path? |
@Tripwire999 Also, have you made the |
@Tripwire999 NVM. Got it working. Looks great. Thanks for the help! |
@acerbetti @Tripwire999 Would you guys be up for submitting a PR that supports storing drawings? We'd like to use this library as a pod in our projects, but we would obviously want to stay up to date on the latest changes. |
Happy to accept and review any PR. But I don't have any bandwidth to maintain the lib right now |
@acerbetti Roger that. I'll submit a PR. |
@JinkProject If you need help I'll be willing to lend a hand for saving and loading the drawings. Though I've modified the AceDrawingView code heavily the saving and loading shouldn't be that different than what i've got. Let me know! |
@Tripwire999 Any help would be appreciated! |
Hi,
I want to save drawing ,when I finish drawing. I can open it again.Please tell me how to do it .Look forward to your reply .Thanks!
The text was updated successfully, but these errors were encountered: