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:
// Add the todo to my iCal calendar
[[myCalendar todos] addObject:newTodo];
would appear to add newTodo to an NSMutableArray, which implicitly
retains it. So this method retains newTodo twice but releases it
once. As a result the todoUid string won't be released, as you
fear, upon sending release to newTodo.
If [myCalendar todos] really is _known_ to be a container that retains
its elements, that's correct. From the original context, though, it
seems it might have been a scripting proxy for the to-do items
contained in a calendar in iCal -- that is, the addObject: actually
communicates with another application. In that case, there is no
reason to believe that newTodo is effectively retained.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]