Re: Should I retain a variable returned from this accessor?

2008-08-13 Thread Negm-Awad Amin
Am Di,12.08.2008 um 21:36 schrieb Shawn Erickson: On Tue, Aug 12, 2008 at 2:12 AM, Negm-Awad Amin [EMAIL PROTECTED] wrote: BTW: You can do the same inside a getter to get rid of thread problems. Nope it does nothing to solve threading issues ([[blah retain] autorelease] isn't an atomic

Re: Should I retain a variable returned from this accessor?

2008-08-13 Thread has
Peter N Lewis wrote: I'm no Cocoa expert, but I think you're wrong on this, you've missed out a crucial line: At 3:12 PM -0400 11/8/08, Sean DeNigris wrote: // Get uid to return NSString* todoUid = [newTodo uid]; // Clean up [newTodo release]; newTodo

Re: Should I retain a variable returned from this accessor?

2008-08-13 Thread mm w
no as far as possible, you shouldn't retain an accessor, you are not the owner of this accessor the accessor is owned by an the his object, you are the owner of an instance of one object when you create it for an example myobject { private dict; } string title(); ... string title() {

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Negm-Awad Amin
Am Di,12.08.2008 um 04:51 schrieb Peter N Lewis: At 4:48 PM -0400 11/8/08, Kyle Sluder wrote: On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris [EMAIL PROTECTED] wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] //

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Negm-Awad Amin
Am Di,12.08.2008 um 14:37 schrieb Sean DeNigris: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] // Get uid to return NSString* todoUid = [newTodo uid]; [...snip...] return todoUid; } you could do: NSString*

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Kyle Sluder
On Mon, Aug 11, 2008 at 10:51 PM, Peter N Lewis [EMAIL PROTECTED] wrote: [newTodo release] is not [newTodo autorelease]. So it may immediately call dealloc and dealloc the uid returned by by [newTodo uid]. You're right about this; I did miss the -release. --Kyle Sluder

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Brian Stern
On Aug 11, 2008, at 10:51 PM, Peter N Lewis wrote: I'm no Cocoa expert, but I think you're wrong on this, you've missed out a crucial line: At 3:12 PM -0400 11/8/08, Sean DeNigris wrote: // Get uid to return NSString* todoUid = [newTodo uid]; // Clean up

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Shawn Erickson
On Tue, Aug 12, 2008 at 2:12 AM, Negm-Awad Amin [EMAIL PROTECTED] wrote: BTW: You can do the same inside a getter to get rid of thread problems. Nope it does nothing to solve threading issues ([[blah retain] autorelease] isn't an atomic operation) you need to protect it with an critical section

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Ken Thomases
On Aug 12, 2008, at 11:51 AM, Brian Stern wrote: On Aug 11, 2008, at 10:51 PM, Peter N Lewis wrote: [newTodo release] is not [newTodo autorelease]. So it may immediately call dealloc and dealloc the uid returned by by [newTodo uid]. To avoid this, you could do: Not really. This line:

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Peter N Lewis
Clearly, there is a lot more going on in the code in this question than in typical Cocoa code. That said, if you want to avoid bugs, it would seem that the following is good advice: * Always use autorelease. * Use an Auto Release Pool if necessary (in loops, or with large memory

Should I retain a variable returned from this accessor?

2008-08-11 Thread Sean DeNigris
Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? I'm using Scripting Bridge to communicate with iCal. Also, this is a sub-routine and todoUid will only be used in the method that calls it. - (NSString*) saveToiCalTodo: (NSString*) theSummary

Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Kyle Sluder
On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris [EMAIL PROTECTED] wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] // Get uid to return NSString* todoUid = [newTodo uid]; [...snip...] return todoUid;

Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Nathan Kinsinger
On Aug 11, 2008, at 1:12 PM, Sean DeNigris wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? I'm using Scripting Bridge to communicate with iCal. Also, this is a sub-routine and todoUid will only be used in the method that calls it.

Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Sean DeNigris
On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris [EMAIL PROTECTED] wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] // Get uid to return NSString* todoUid = [newTodo uid]; [...snip...] [newTodo release];

Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Peter N Lewis
At 4:48 PM -0400 11/8/08, Kyle Sluder wrote: On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris [EMAIL PROTECTED] wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] // Get uid to return NSString* todoUid =