0

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?

1
  • Show us the code for a real answer, but in this case, it sounds like you have a bad global variable declaration/initialization. Commented Jun 24, 2010 at 21:51

1 Answer 1

2

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, that worked, I am still a little used to java, trying to learn objective c and the iphone framework in parallel. I have a problem with the code, I am trying to load an image to set the background image depending on whether the user chooses next or previous button. I am calling the object at an index which I increment or decrement and I can see that the counter is increasing and decreasing accordingly when they press the buttons. What would the could look like to set the background of my view controller?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.