Re: NSMutableDictionary autorelease chrashes application

2008-07-19 Thread Michael Ash
On Fri, Jul 18, 2008 at 11:52 PM, Andy Lee [EMAIL PROTECTED] wrote: The only unusual thing Cocoa does with it is allow multiple owners. I'm confused by this statement. Take that simple C++ String class again. If you have: String a = aaa; String b = a; String c = a; ...don't

Re: NSMutableDictionary autorelease chrashes application

2008-07-19 Thread Uli Kusterer
On 19.07.2008, at 05:52, Andy Lee wrote: It's only when the ownership metaphor was applied that I questioned whether the abstraction holds up. It's a metaphor, an abstraction. As those things go, they're bound to break down at some point. ownership works, because it's a term already

Re: NSMutableDictionary autorelease chrashes application

2008-07-19 Thread Uli Kusterer
On 19.07.2008, at 05:52, Andy Lee wrote: I'm confused by this statement. Take that simple C++ String class again. If you have: String a = aaa; String b = a; String c = a; ...don't a, b, and c all own the underlying char buffer? (And yes, a char buffer isn't an object, but that's

Re: NSMutableDictionary autorelease chrashes application

2008-07-19 Thread Andy Lee
On Jul 19, 2008, at 10:52 AM, Uli Kusterer wrote: On 19.07.2008, at 05:52, Andy Lee wrote: It's only when the ownership metaphor was applied that I questioned whether the abstraction holds up. It's a metaphor, an abstraction. As those things go, they're bound to break down at some point.

Re: NSMutableDictionary autorelease chrashes application

2008-07-19 Thread Andy Lee
On Jul 19, 2008, at 11:11 AM, Uli Kusterer wrote: On 19.07.2008, at 05:52, Andy Lee wrote: I'm confused by this statement. Take that simple C++ String class again. If you have: String a = aaa; String b = a; String c = a; ...don't a, b, and c all own the underlying char buffer? (And

NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Matthias Arndt
Hi! I'm a rookie with Cocoa development, please excuse if this question is stupid, but I'm struck with memory management (an even Aaron's book doesn't help me): In a method I use a (temporary) dictionary vAttributes to read an object from an instance variable vColors (a dictionary, too):

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Keary Suska
7/18/08 7:48 AM, also sprach [EMAIL PROTECTED]: In a method I use a (temporary) dictionary vAttributes to read an object from an instance variable vColors (a dictionary, too): - (NSString *)descriptionByColorCode:(int)colorCode { NSMutableDictionary *vAttributes = [[NSMutableDictionary

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Robert Martin
In the code you provide, the first line allocates a brand new dictionary and assigns it to vAttributes. In the next line, you reassign vAttributes to the contents of your iVar dictionary. Nothing points to that alloc'd dictionary in the first line anymore. Since vAttributes now points to

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Matthias Arndt
Robert, Am 18.07.2008 um 16:25 schrieb Robert Martin: In the next line, you reassign vAttributes to the contents of your iVar dictionary. Nothing points to that alloc'd dictionary in the first line anymore. Since vAttributes now points to an autoreleased dictionary, attempting to

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Shawn Erickson
On Fri, Jul 18, 2008 at 7:34 AM, Matthias Arndt [EMAIL PROTECTED] wrote: Robert, Am 18.07.2008 um 16:25 schrieb Robert Martin: In the next line, you reassign vAttributes to the contents of your iVar dictionary. Nothing points to that alloc'd dictionary in the first line anymore. Since

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Trygve Inda
Hi! I'm a rookie with Cocoa development, please excuse if this question is stupid, but I'm struck with memory management (an even Aaron's book doesn't help me): In a method I use a (temporary) dictionary vAttributes to read an object from an instance variable vColors (a dictionary, too):

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Matthias Arndt
Am 18.07.2008 um 16:42 schrieb Shawn Erickson: This is the wrong thing to take away from this email thread. Please review the following and ask questions if you don't understand any aspect of it.

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Shawn Erickson
On Fri, Jul 18, 2008 at 7:42 AM, Shawn Erickson [EMAIL PROTECTED] wrote: On Fri, Jul 18, 2008 at 7:34 AM, Matthias Arndt [EMAIL PROTECTED] wrote: Robert, Am 18.07.2008 um 16:25 schrieb Robert Martin: In the next line, you reassign vAttributes to the contents of your iVar dictionary.

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 10:49 AM, Shawn Erickson wrote: I should more clearly note that objectForKey: is not returning an autoreleased object. Also even if it did it would be an implementation detail (unless documented in the API docs). It is returning a reference to an object that the vColors

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 1:20 PM, Andy Lee wrote: On Jul 18, 2008, at 10:49 AM, Shawn Erickson wrote: I should more clearly note that objectForKey: is not returning an autoreleased object. Also even if it did it would be an implementation detail (unless documented in the API docs). It is returning

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread mmalc crawford
On Jul 18, 2008, at 1:20 PM, Andy Lee wrote: Unless Apple defines another adjective for this purpose, it seems to me that autoreleased is a reasonable shorthand for you must retain it if you want it to stick around, or you *may* have a dangling pointer. Similarly, retained is a reasonable

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Shawn Erickson
On Fri, Jul 18, 2008 at 10:20 AM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 10:49 AM, Shawn Erickson wrote: I should more clearly note that objectForKey: is not returning an autoreleased object. Also even if it did it would be an implementation detail (unless documented in the API

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 2:17 PM, mmalc crawford wrote: On Jul 18, 2008, at 1:20 PM, Andy Lee wrote: Unless Apple defines another adjective for this purpose, it seems to me that autoreleased is a reasonable shorthand for you must retain it if you want it to stick around, or you *may* have a

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread j o a r
On Jul 18, 2008, at 11:51 AM, Andy Lee wrote: I don't see the difference from the caller's point of view. There isn't any, and that was not MMalcs point. His point was that you were using the term autoreleased incorrectly. j o a r ___

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 2:27 PM, Shawn Erickson wrote: On Fri, Jul 18, 2008 at 10:20 AM, Andy Lee [EMAIL PROTECTED] wrote: Unless Apple defines another adjective for this purpose, it seems to me that autoreleased is a reasonable shorthand for you must retain it if you want it to stick around, or

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 2:59 PM, j o a r wrote: On Jul 18, 2008, at 11:51 AM, Andy Lee wrote: I don't see the difference from the caller's point of view. There isn't any, and that was not MMalcs point. His point was that you were using the term autoreleased incorrectly. I don't think I have

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread mmalc crawford
On Jul 18, 2008, at 11:51 AM, Andy Lee wrote: Autoreleased is inaccurate and is not a proper shorthand for you must retain it if you want it to stick around. To understand why, consider two possible implementations of a get accessor: - (NSString *)name { return name; } - (NSString

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 3:49 PM, Michael Ash wrote: I don't see any reason to use autoreleased in a situation where the object in question has not, in fact, been sent the autorelease method. It's just confusing. Yes, you would have to acknowledge that you don't know whether autorelease has in

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 4:19 PM, mmalc crawford wrote: On Jul 18, 2008, at 11:51 AM, Andy Lee wrote: Autoreleased is inaccurate and is not a proper shorthand for you must retain it if you want it to stick around. To understand why, consider two possible implementations of a get accessor: -

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread mmalc crawford
On Jul 18, 2008, at 1:48 PM, Andy Lee wrote: On Jul 18, 2008, at 4:19 PM, mmalc crawford wrote: On Jul 18, 2008, at 11:51 AM, Andy Lee wrote: NSString *name = [aPerson name]; [aPerson setName:@Fido]; NSLog(@Old name: %@, name); And calling the return value from -name autoreleased would

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 4:55 PM, Hamish Allan wrote: On Fri, Jul 18, 2008 at 9:21 PM, Andy Lee [EMAIL PROTECTED] wrote: What would you use for adjectives -- owned and unowned? How about retained and unretained? As in: this method returns an unretained object. Unfortunately, there's no such

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Michael Vannorsdel
In my office we usually call objects returned directly without an autorelease as short returned and an retain-autoreleased object as pooled. Though these sound more slang than something that could be official. On Jul 18, 2008, at 3:10 PM, Andy Lee wrote: Unfortunately, there's no such

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Michael Ash
On Fri, Jul 18, 2008 at 4:21 PM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 3:49 PM, Michael Ash wrote: The better term already exists: own. As in, you own the return value or you do not own the return value. This tells you everything you need to know. Well, as I said I don't

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 6:41 PM, Michael Ash wrote: On Fri, Jul 18, 2008 at 4:21 PM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 3:49 PM, Michael Ash wrote: The better term already exists: own. As in, you own the return value or you do not own the return value. This tells you

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Hamish Allan
On Fri, Jul 18, 2008 at 9:21 PM, Andy Lee [EMAIL PROTECTED] wrote: What would you use for adjectives -- owned and unowned? How about retained and unretained? As in: this method returns an unretained object. Hamish ___ Cocoa-dev mailing list

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Hamish Allan
On Fri, Jul 18, 2008 at 10:10 PM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 4:55 PM, Hamish Allan wrote: On Fri, Jul 18, 2008 at 9:21 PM, Andy Lee [EMAIL PROTECTED] wrote: What would you use for adjectives -- owned and unowned? How about retained and unretained? As in: this

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Michael Ash
On Fri, Jul 18, 2008 at 7:48 PM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 6:41 PM, Michael Ash wrote: On Fri, Jul 18, 2008 at 4:21 PM, Andy Lee [EMAIL PROTECTED] wrote: On Jul 18, 2008, at 3:49 PM, Michael Ash wrote: The better term already exists: own. As in, you own the

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Steve Weller
On Jul 18, 2008, at 1:55 PM, Hamish Allan wrote: On Fri, Jul 18, 2008 at 9:21 PM, Andy Lee [EMAIL PROTECTED] wrote: What would you use for adjectives -- owned and unowned? How about retained and unretained? As in: this method returns an unretained object. How about dependent and

Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Andy Lee
On Jul 18, 2008, at 8:31 PM, Michael Ash wrote: On Fri, Jul 18, 2008 at 7:48 PM, Andy Lee [EMAIL PROTECTED] wrote: We'll just have to disagree on how odd the objections are. Corner case or not, we must understand that retains, wherever they occur, must be balanced with releases. Therefore