• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessor methods and (auto)release: conclusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor methods and (auto)release: conclusion


  • Subject: Re: Accessor methods and (auto)release: conclusion
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 6 Aug 2002 19:23:32 +0200

On Tuesday, August 6, 2002, at 07:07 , Marco Scheurer wrote:

id s=[[doc window] title];
[doc save];
if ([s length]) ... CRASH! WOW!

As I said, but it looks like you prefer to ignore it, not crashing does make the code correct. The correct(*) code in that case would one of:

id s = [[[doc window] title] copy];

Actually, it would have to be

id s=[[[[doc window] title] copy] autorelease];

but the thing is, as least as I understand Cocoa, this is not needed -- copying is a vendor's responsibility.

I've bumped into this already once or twice, eg.

From: Ondra Cada <email@hidden>
Date: Tue Aug 06, 2002 07:21:12 Europe/Prague
To: Ondra Cada <email@hidden>
Cc: Marcel Weiher <email@hidden>, Marco Scheurer <email@hidden>
, email@hidden, Ali Ozer <email@hidden>
Subject: Re: Accessor methods and (auto)release: conclusion
...
(b) nevertheless, accessors should IMHO never vend mutable objects, unless explicitly documented so. That is another thing very worth enlightening in Cocoa; I would advocate though first finish this debate, and then start "when copy" one.

As said, not to make this debate too complex (seems to me it's enough so already), I would delay discussing this (also very very interesting!) point after we find some conclusion of the autorelease stuff we are just now discussing.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: Accessor methods and (auto)release: conclusion (From: Marco Scheurer <email@hidden>)

  • Prev by Date: Re: Accessor methods and (auto)release: conclusion
  • Next by Date: Re: Distributed Objects over a Network
  • Previous by thread: Re: Accessor methods and (auto)release: conclusion
  • Next by thread: Re: Accessor methods and (auto)release: conclusion
  • Index(es):
    • Date
    • Thread