• 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: Objective-C runtime questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C runtime questions


  • Subject: Re: Objective-C runtime questions
  • From: Nicko van Someren <email@hidden>
  • Date: Sun, 27 Feb 2005 14:46:14 +0000


On 27 Feb 2005, at 13:54, Stéphane Sudre wrote:

I was reading the old NeXT Developer's Library documentation entitled: "Object-Oriented Programming and the Objective-C Language" and I came across 2 points I'm wondering about:

- it is stated that the default returned value of a message sent to nil for a method which returns an object is nil but that it is undefined if the method does not return an object.

My experience has been somehow that 0 was returned in such cases. Is it just good luck?

As far as I can tell the current implementation returns 0 for all numeric or pseudo-numeric types (like chars). If however the value returns is a structure (such as an NSRect or NSPoint) then the current implementation literally does not return anything; the value of the l-value to which you assign the result does not change. This is because return values that don't fit in registers are passed by reference.


While it is documented as undefined I think that you are probably pretty safe with expecting (int) returns to be zero on messages to nil objects but I would avoid relying on it on any other type.

- it is said that you can unload Objective-C modules (Page 104).

Yet, AFAIK, you can load a NSBundle but you can't unload it. So is it just an issue with NSBundle that can be worked around?

I've no idea if you can but I suspect that on modern machines you would very seldom actually need to do so since the code size of most programs is a very small fraction of their working set. In fact s o m e on this list might suggest it worrying about such memory consumption issues smacks of premature optimisation ;-)


	Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Objective-C runtime questions
      • From: Stéphane Sudre <email@hidden>
References: 
 >Objective-C runtime questions (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Re: Objective-C runtime questions
  • Next by Date: Re: Objective-C runtime questions
  • Previous by thread: Re: Objective-C runtime questions
  • Next by thread: Re: Objective-C runtime questions
  • Index(es):
    • Date
    • Thread