I'm just learning Objective C and need to understand how to declare and use a static NSArray. I think I may be confusing the Java concept of static and Objective C's concept.

What I want is how to use the Java idea of a class static variable in Objective C

Here's the code I'm trying to use:

//class name is Person
static          NSMutableArray* relationshipMatch;

-(id)init {
        [super init];
        if (relationshipMatch==nil)     
                [Person initRelationshipMatch];
        return self;
}
+ (void) initRelationshipMatch  {
        relationshipMatch = [NSArray arrayWithObjects:
                @"abc",@"def",@"hig",nil] ;       
}


When I try to access the array using
NSString* aString = [relationshipMatch objectAtIndex:1];

I get
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '***

Any help would be appreciated.

Richard Good

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to