• 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: Looking for Cocoa source code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for Cocoa source code


  • Subject: Re: Looking for Cocoa source code
  • From: David Remahl <email@hidden>
  • Date: Thu, 6 Mar 2003 20:07:52 +0100

Apple is keeping the source to themselves, and this is actually good in some cases, since it enforces encapsulation and forces you to rely only on what is documented. The thing is, that the developer should not know exactly what he/she is overriding, since that can change in future implementations of the framework, and then break existing >> code.

If you find problems in the documentation, file bugs against it at <http://bugreporter.apple.com>.

That is true to a point, but here is a good example of why it is not good:

If you write a subclass of NSView and think you need to overload these methods:

- (void)setFrameOrigin:(NSPoint)newOrigin;
- (void)setFrameSize:(NSSize)newSize;
- (void)setFrame:(NSRect)frameRect;

which one do you overload? all of them?

It might help to know that setFrame: calls setFrameSize: and setFrameOrigin: to do its job.

Thus you need to overload setFrameSize: and setFrameOrigin: only. And if you also overload setFrame: then you might be screwed because you might do some things twice.

It pays to know the implementation details.

No, because it is subject to change. What if the primary method in the next release of cocoa is changed? So that setFrame: no longer calls setFrameOrigin:? You can only trust setFrame: to call setFrameOrigin: if it is documented to do so. Apple *should* document that fact, if they can keep the promise in the future.

File a bug on the documentation or the framework, or both, if you would like Apple to say this in the future. But I don't think it is necessary, since overriding those methods in almost all cases can be solved using a delegate or notifications. So, if you do need to override them, you should override all of them at this point (and override setFrame: to call setFrameOrigin: and setFrameSize:).

/ David
_______________________________________________
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.

  • Follow-Ups:
    • Re: Looking for Cocoa source code
      • From: Lance Bland <email@hidden>
References: 
 >Re: Looking for Cocoa source code (From: Lance Bland <email@hidden>)

  • Prev by Date: Re: Looking for Cocoa source code
  • Next by Date: Re: Looking for Cocoa source code
  • Previous by thread: Re: Looking for Cocoa source code
  • Next by thread: Re: Looking for Cocoa source code
  • Index(es):
    • Date
    • Thread