收录日期:2020/12/04 08:01:11 时间:2010-06-24 21:50:25 标签:iphone,objective-c,nsarray

Really beginner question here.

I have an NSArray of images which in its last line has an error in Xcode saying that the "initializer element is not constant".

any help please?

You're initializing your NSArray outside of a valid scope (ie, not inside a function or method).

For example, the following will produce your error:

NSArray * foo = [NSArray array];
int main(int argc, char * argv[]) {
  return 0;
}

To fix it, you'd do something like:

NSArray * foo = nil;
int main(int argc, char * argv[]) {
  foo = [NSArray array];
  return 0;
}