Re: NSArray as a static
Re: NSArray as a static
- Subject: Re: NSArray as a static
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 2 Sep 2008 09:33:42 +0200
Le 2 sept. 08 à 00:13, Steven Noyes a écrit :
On Sep 1, 2008, at 1:38 PM, Jean-Daniel Dupas wrote:
Unlike java, Obj-C does not have the concept of class variable.
Your static variable is a classic C variable, and C variable are
not automatically initialized to NULL.
The first time you call init, relationshipMatch may contains
anything and may not be NULL, and so it will never be properly
initialized.
Note: In "C", all static and global variables are initialized to
zeros (or NULL pointers). Local variables (auto variables from the
stack) are not initialized.
Steven
Yep, I just saw that static are an exception and are initialized to
NULL or 0, but I'm not sure about "globals".
10 If an object that has automatic storage duration is not initialized
explicitly, its value is
indeterminate. If an object that has static storage duration is not
initialized explicitly,
then:
—ifithas pointer type, it is initialized to a null pointer;
—ifithas arithmetic type, it is initialized to (positive orunsigned)
zero;
—ifitisanaggregate, every member is initialized (recursively)
according to these rules;
—ifit isaunion, the first named member is initialized (recursively)
according to these
rules.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden