Skip to content
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

Can we save current drawing for later use and start another fresh drawing ? #13

Open
KrLikeblue opened this issue Jan 9, 2017 · 6 comments

Comments

@KrLikeblue
Copy link

Hello Adam, It's me again :)

I want to ask you that, I want to save current drawing for later use and want to start another fresh drawing, So is it possible ?

Basically I want to know that can we save as many files as we want ? and when we use them again, that particular file must have previous drawing which we had drawn on it.

Waiting for your great answer.

Thanks.

@adamwulf
Copy link
Owner

adamwulf commented Jan 9, 2017

Yep! check out the loadState: method to load from disk, and use the exportImageTo:exportThumbnailTo:andStateTo:withThumbnailScale:onComplete: to save to disk. Loose Leaf handles save/load in the https://github.com/adamwulf/loose-leaf/blob/master/Project/LooseLeaf/MMEditablePaperView.m class as an example.

@KrLikeblue
Copy link
Author

I understood it.. :)

Will try it.

Thanks.

@KrLikeblue
Copy link
Author

Hello Adam,

There is one bug while saving multiple drawing items.

All drawings are being saved successfully when I call "exportImageTo:" for saving.

But when I tried to load any previous drawing, then it comes blank.

When I try to load current drawing, then that drawing is appearing.

The reason is all previous .strokedata files are removed from documents directory folder when you save current drawing .strokedata files

And bug is in #import "JotViewImmutableState.m" file

here are lines of code which cause this bug
NSArray* contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:stateDirectory error:nil];
for (NSString* item in contents) {
NSString* fileInDir = [stateDirectory stringByAppendingPathComponent:item];
if (![fileNamesOfStrokes containsObject:fileInDir] && [[fileInDir pathExtension] isEqualToString:kJotStrokeFileExt]) {
[[NSFileManager defaultManager] removeItemAtPath:fileInDir error:nil];
}
}

I have commented above code and then I can access all my drawings.

So I have commented that code, will It cause any problem for my drawings ?

Waiting for an answer.
Thanks.

@adamwulf
Copy link
Owner

Instead of saving all drawings to the same directory, you should be saving each to their own directory. Use the delegate methods during load/save, and return different directories for each drawing. Otherwise, you'll find that the ink.png and thumb.png are constantly overridden as well if you continue saving into the same directory.

@KrLikeblue
Copy link
Author

So you mean to say, I will have to create different folder in documents directory every time I start drawing fresh ? In your example, you are saving all in just documents directory folder.

And Right now what I am doing is, I am naming "ink.png" ad "thumb.png" different names for every drawing like "ink1.png" "thumb1.png" , "ink2.png" "thumb2.png" like this, so i think they will not override, What I want to ask you is, can stroke path(saved in documents directory) of different drawing be overridden ? or they will be unique ?

@adamwulf
Copy link
Owner

ah - if you're renaming the ink/thumb pngs, then it should be ok to keep the strokedata all in the same directory. they'll be unique for each drawing. though i initially designed it to be saved per-folder, just to keep things clean and separate. if it works for you to stay in 1 folder, that'll work fine though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants