How do I declare an array as a constant in Objective-c?

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-12T23:04:24Z Indexed on 2010/03/12 23:07 UTC
Read the original article Hit count: 252

Filed under:
|
|

The following code is giving me errors:

//  constants.h
extern NSArray const *testArray;
//  constants.m
NSArray const *testArray = [NSArray arrayWithObjects:  @"foo", @"bar"];

The error I get is
initializer element is not constant

Or if I take away the pointer indicator (*) I get:
statically allocated instance of Objective-C class 'NSArray'

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about constants