Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-06 Thread Charles Srstka
On Feb 6, 2011, at 6:35 AM, Jerry Krinock wrote: > On 2011 Feb 05, at 21:16, Charles Srstka wrote: > >>> During execution, I'd see the following: >>> >>> (timestamp) (code location) someObjectName: allocated >>> (timestamp) (code location) someObjectName: init >>> (timestamp) (code location) som

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-06 Thread Jerry Krinock
On 2011 Feb 05, at 21:16, Charles Srstka wrote: >> During execution, I'd see the following: >> >> (timestamp) (code location) someObjectName: allocated >> (timestamp) (code location) someObjectName: init >> (timestamp) (code location) someObjectName: retained >> (timestamp) (code location) someO

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-05 Thread Charles Srstka
On Feb 5, 2011, at 6:37 PM, John Bartleson wrote: > Let me make one final point: this topic would have never come up if I had had > a tool that would let me track the > lifetime of an object. Very hypothetically, suppose I could write my code, > execute it, and then, in the debugger or > whateve

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-05 Thread Jerry Krinock
On 2011 Feb 05, at 16:37, John Bartleson wrote: > A lot of the confusion comes about because of poor documentation. That's one of the main reasons for using Graham's open-source GCUndoManager. > whatever, could issue a command like "Track someObjectName". During > execution, I'd see the follow

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-05 Thread Graham Cox
On 06/02/2011, at 11:37 AM, John Bartleson wrote: > A lot of the confusion comes about because of poor documentation. Apple's > "Introduction to Undo > Architecture" doesn't clearly explain that the sequence beginning with > prepareWithInvocationTarget: > results in NSUndoManager effectively ta

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-02-05 Thread John Bartleson
Sorry, I was busy and couldn't reply. Now it's time to finish this thread. Graham Cox said: In the middle step, why should YOU worry about whether the undo manager has retained 'descriptorsCopy'? It's not your responsibility how that object works. It might have retained the object, copied

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-14 Thread Graham Cox
On 15/01/2011, at 4:50 AM, Uli Kusterer wrote: > Guys, why is sorting like this even an undo-able action in your apps ... ? > That's pointless. Not always pointless. Probably mostly. Depends on the app. Personally I have never bothered to make sorting undoable - I was thinking hypothetically

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-14 Thread Uli Kusterer
On Jan 11, 2011, at 7:35 AM, Jerry Krinock wrote: > On 2011 Jan 10, at 21:39, Graham Cox wrote: > >> As suggested, to undo a sort, pass the old descriptors to the undo manager >> and when undo is invoked, it restores the old descriptors and once again >> invalidates the cache. > > But that assu

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-14 Thread Gary L. Wade
> I'm sure you'd agree that when we're learning a new environment, references > and documentation are only > part of the process. If we can't figure out the docs, and lacking an expert > in the next cubicle to ask, > then writing a test app will usually quickly answer our question. This is > whe

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-13 Thread Graham Cox
On 14/01/2011, at 5:58 PM, John Bartleson wrote: > I'm glad to see this, because it's really the answer to my original question. > Poking around a little, one finds > NSInvocation's retainArguments method, which is probably what NSUndoManager > uses. > > You've stated that I "only need to foll

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-13 Thread John Bartleson
Graham: thanks for your comment and thanks for being patient with a relative n00b. Hopefully we can nail this topic down in a post or two. You are not required to verify it. (Though you may do so using the memory tracing tools). You only need to follow the rules, and understand that the und

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-13 Thread Graham Cox
On 13/01/2011, at 7:52 PM, John Bartleson wrote: > The real point of my original plaintive cry, and I'm sorry if it's become > obfuscated, is that I > had to allocate memory as part of setting up for undo, but I couldn't find > any *simple* way to > keep track of whether that memory is still in

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-13 Thread John Bartleson
Thank you all for your comments. Because I think this is an important topic (and because I'm stubborn) I'm going to continue to beat it to death. Because there were a number of issues brought up in the comments, let me summarize them, with my responses in line: ** Comment 1 (Graham Cox, Jan

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Dave Fernandes
And I'd love to know a trick to bring the correct tab to the front when undoing/redoing changes in a tabbed interface. On 2011-01-11, at 2:00 PM, Jerry Krinock wrote: > > On 2011 Jan 11, at 08:35, Sean McBride wrote: > >> For one, there doesn't seem to be a nice way to get the Undo menu item t

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Jerry Krinock
On 2011 Jan 11, at 08:35, Sean McBride wrote: > For one, there doesn't seem to be a nice way to get the Undo menu item to > say descriptive things like "Undo Typing", "Redo Size Change", etc. > When doing things 'the hard way' that part's actually easier. Oh, yes. In my original draft of that p

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Sean McBride
On Mon, 10 Jan 2011 22:35:28 -0800, Jerry Krinock said: >Aside: Reading this thread really makes one appreciate Core Data. > >I've written a Core Data app which can Undo Sort. The sortable objects >are the 'many' members of to-many relationships. Each one has an >'index' parameter, which is re-s

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Jerry Krinock
On 2011 Jan 11, at 03:27, steven Hooley wrote: > either : > > a) sort order is a property of the window, not your model and > shouldn't be undoable at all… > > OR b) > > the sort order is inherently part of your model True, and I agree with Graham that it depends on the app. The app I descri

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Graham Cox
On 11/01/2011, at 10:27 PM, steven Hooley wrote: > I don't mean to hijack this thread, but my first thought, for what > it's worth is that either :- > > a) sort order is a property of the window, not your model and > shouldn't be undoable at all. I agree. In fact I don't typically make sorting

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread steven Hooley
I don't mean to hijack this thread, but my first thought, for what it's worth is that either :- a) sort order is a property of the window, not your model and shouldn't be undoable at all. What happens if you want another view - say a grid view, with nice big icons - of the same data?. Should that

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-11 Thread Graham Cox
On 11/01/2011, at 5:35 PM, Jerry Krinock wrote: > But that assumes that the data was sorted with some old descriptors to begin > with. It seems like this would not work if the objects had been manually > arranged into some arbitrary order by the user. True, but then you'd make the reordering

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-10 Thread Jerry Krinock
On 2011 Jan 10, at 21:39, Graham Cox wrote: > As suggested, to undo a sort, pass the old descriptors to the undo manager > and when undo is invoked, it restores the old descriptors and once again > invalidates the cache. But that assumes that the data was sorted with some old descriptors to be

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-10 Thread Graham Cox
My first thought, before I go further, is that to undo a sort, you are doing things way too complicated. You only need to pass the sort descriptors to the undo manager, not a copy of the data. Presumably adding and removing items in the data itself is also undoable, so at any time the data on wh

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-10 Thread John Bartleson
Thanks for your replies. I'm hoping that the conclusion will help others who are confused by the existing documentation of MM in NSUndoManager. So here's what I'm doing: My reference-counted, document-based app uses a table view. The table view supports sorting by clicking in the header. The

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-09 Thread Graham Cox
Actually, it doesn't really matter what NSUndoManager does with arguments, all you really need to know is that it follows the rules for ownership of objects, so by and large does the 'right thing'. It does lots of wrong things, IMO, but incorrect memory management isn't among them. You're right

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-09 Thread Jerry Krinock
On Sun, Jan 9, 2011 at 12:19 AM, John Bartleson wrote: > Can someone PUH-LEASE clear up the confusion re NSUndoManager > retaining/releasing arguments to prepareWithInvocationTarget:? PUH-LEASE stop beating your head against a black box! Replace the inexplicable NSUndoManager with Graham Cox'

Re: NSUndoManager retain/release of arguments - ad infinitum

2011-01-09 Thread Kyle Sluder
On Sun, Jan 9, 2011 at 12:19 AM, John Bartleson wrote: > Can someone PUH-LEASE clear up the confusion re NSUndoManager > retaining/releasing arguments to prepareWithInvocationTarget:? I suppose it would be more helpful to describe what you're trying to do and why it's not working for you. I've r

NSUndoManager retain/release of arguments - ad infinitum

2011-01-09 Thread John Bartleson
Can someone PUH-LEASE clear up the confusion re NSUndoManager retaining/releasing arguments to prepareWithInvocationTarget:? In various places in cocoa-dev and in referenced 'net articles, such as here and here