| Article: |
Animating Graphics in Cocoa, Part 1 | |
| Subject: | Archiving graphics | |
| Date: | 2002-01-17 11:11:10 | |
| From: | michele | |
|
Hello Mike,
|
||
Showing messages 1 through 5 of 5.
-
Archiving example
2002-01-19 00:11:28 psheldon [View]
-
Archiving graphics
2002-01-18 14:47:49 michele [View]
Hello Mike,
Thanks to nice guys at cocoa-dev mailing list and after a whole day tracking memory leaks, archiving and unarchiving works almost fine with an NSMutableDictionary.
Saving and opening works fine, but closing the window calls the save panel only when an IBAction occured (changing colors and line widths).
I still don't know how to tell the document that the view has changed after a mouse event has occured (paths are drawn by defining a rectangle from mouse down, mouse dragged, and mouse up events).
Any idea?
Thanks in advance,
Michèle
-
Archiving graphics
2002-01-20 11:17:34 Michael Beam |
[View]
you might want to look into converting this application into a document based application. When you say you "don't know how to tell the document that the view has changed after a mouse event has occured" do you mean to tell the document to redraw itself or to not let you close the document without asking you to save unsaved changes?
For your other question in the previous post i would have gone the route you did with the NSMutableDictionary.
Mike -
Archiving graphics
2002-01-20 14:29:24 michele [View]
Hello Mike,
I mean not let me close the document without asking me to save unsaved changes.
I've already converted the application into a document based application, added synchronisation between colors (background and brush) and color wells as well as line width and line width slider on opening a document.
It works fine as long as I don't close the window or quit the application without closing a changed document.
Thanks for your help,
Michèle
-
Archiving graphics
2002-01-23 21:08:29 Michael Beam |
[View]
Ah, i see. You want to tell the document that you've made a change to something important and it shouldn't let you close the document window without providing some feedback that there are unsaved changes. This is actually pretty easy.
When you modify the document's data (I'm assuming the code that does this is in your NSDocument subclass) you want to use the NSDocument method
-updateChangeCount:. The argument to this is one of three constants: NSChangeDone, NSChangeUndone, and NSChangeCleared. So, in your method that modifies your data you would want to have executed is:
[self updateChangeCount:NSChangeDone];
This will mark your document as having unsaved changes. The reason for the complexity of this is to support the undo system. I hope i answered the correct question and that the answer was helpful.
BTW, i'm working on the your question about the tablecolumn thing from several, several columns ago. I think a future column will cover it, but if you want to know what i'm thinking feel free to email me and i'll share with you. Talk to you later!
Mike



http://www.oreillynet.com/pub/ct/37
lists all the columns Mike wrote. You seem to have come in late and maybe missed one of the columns.
I've read and programmed from every one, but still feel like a newby. I think it is getting easier to read a column and lingo gets more and more familiar, so I am learning something.
When cocoa first came out, I ventured out on my own alot thinking I could somehow debug immature early documentation and make it grow strong. It was confusing and now I wait for Mike's column but sometimes catch fire with a solo attempt again. The last four days I've gotten dizzy with Maple problem wherein I caught fire.
On the above list of columns, is a link to an address book which, I recall, showed a number of ways to save stuff.
First to build the address book :
http://www.oreillynet.com/pub/a/mac/2001/08/10/cocoa.html
Next to save it various ways :
http://www.oreillynet.com/pub/a/mac/2001/08/24/cocoa.html
Perhaps, in your having struggled with saving graphics, this will firm up the memories for you. Remember, life will have you revisit useful stuff and then you'll be able to relearn it faster than you originally learned it.
;-)