Re: NSArray as a static

2008-09-02 Thread Clark Cox
On Tue, Sep 2, 2008 at 8:45 AM, Richard Good <[EMAIL PROTECTED]> wrote: > It appears that the line >> >> static NSArray* constants = nil; > > is only being executed on the first call to the method and being ignored on > all subsequent calls. > Could someone please explain why? Thanks. That's th

Re: NSArray as a static

2008-09-02 Thread Shawn Erickson
On Tue, Sep 2, 2008 at 8:45 AM, Richard Good <[EMAIL PROTECTED]> wrote: > Could someone please explain why? Thanks. That is how static is _defined_ to behave. The initialization only takes place once. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@list

Re: NSArray as a static

2008-09-02 Thread Richard Good
First I do appreciate the help. The code suggested below does what I need it to, but I don't understand something (probably the semantics of 'static'). I know the constants are set only once as I traced the code but, it sure seems like they should be set each time the method is called. I

Re: NSArray as a static

2008-09-02 Thread Jean-Daniel Dupas
Le 2 sept. 08 à 16:29, Clark Cox a écrit : On Tue, Sep 2, 2008 at 12:33 AM, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote: 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

Re: NSArray as a static

2008-09-02 Thread Clark Cox
On Tue, Sep 2, 2008 at 12:33 AM, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote: > > 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

Re: NSArray as a static

2008-09-02 Thread Jean-Daniel Dupas
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

Re: NSArray as a static

2008-09-01 Thread Graham Cox
On 2 Sep 2008, at 6:47 am, Richard Good wrote: So let me rephrase the question How do I create an array of constant strings such that I have only one instance for the entire class, or is that just not possible. If its not possible how do you approach the problem in Objective C. for exampl

Re: NSArray as a static

2008-09-01 Thread Shawn Erickson
On Mon, Sep 1, 2008 at 1:47 PM, Richard Good <[EMAIL PROTECTED]> wrote: > I'm trying to create an array of string constants to be used inside the > Person class. > So let me rephrase the question How do I create an array of constant strings > such that I have only one instance for the entire class

Re: NSArray as a static

2008-09-01 Thread Steven Noyes
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

Re: NSArray as a static

2008-09-01 Thread Kyle Sluder
On Mon, Sep 1, 2008 at 4:47 PM, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote: > It will not compile: *facepalm* Code written in e-mail, yada yada... --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests

Re: NSArray as a static

2008-09-01 Thread Adam R. Maxwell
On Sep 1, 2008, at 11:38 AM, 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

Re: NSArray as a static

2008-09-01 Thread Clark Cox
On Mon, Sep 1, 2008 at 11:38 AM, Jean-Daniel Dupas <[EMAIL PROTECTED]> 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. Note, for static variables, this is not true.

Re: NSArray as a static

2008-09-01 Thread Jean-Daniel Dupas
Le 1 sept. 08 à 21:18, Kyle Sluder a écrit : On Mon, Sep 1, 2008 at 2:29 PM, Richard Good <[EMAIL PROTECTED]> wrote: What I want is how to use the Java idea of a class static variable in Objective C Because Objective-C doesn't have class variables (as Jean-Daniel noted), you have to use

Re: NSArray as a static

2008-09-01 Thread Richard Good
Very cogent description, but I'm not trying to access the array from outside of the class. I'm trying to create an array of string constants to be used inside the Person class. So let me rephrase the question How do I create an array of constant strings such that I have only one instance for

Re: NSArray as a static

2008-09-01 Thread Kyle Sluder
On Mon, Sep 1, 2008 at 2:29 PM, Richard Good <[EMAIL PROTECTED]> wrote: > What I want is how to use the Java idea of a class static variable in > Objective C Because Objective-C doesn't have class variables (as Jean-Daniel noted), you have to use a global variable. The "static" keyword in C mean

Re: NSArray as a static

2008-09-01 Thread Jean-Daniel Dupas
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 in