This code might look valid to less experienced iOS developers, but it does give a compiler error "initializer element is not constant":
static NSArray *playState = [NSArray arrayWithObjects:The problem is that variable playState is a constant, whose value depends on other variable, whose value is not known. Seems like Objective-C standard does not allow that kind of initialization setup
@"MPMoviePlaybackStateStopped",
@"MPMoviePlaybackStatePlaying",
@"MPMoviePlaybackStatePaused",
@"MPMoviePlaybackStateInterrupted",
@"MPMoviePlaybackStateSeekingForward",
@"MPMoviePlaybackStateSeekingBackward",
nil];
Fix it like this:
static NSArray *playState = nil;Congratulations! Welcome to the selected group of more experienced iOS developers!
playState = [NSArray arrayWithObjects:
@"MPMoviePlaybackStateStopped",
@"MPMoviePlaybackStatePlaying",
@"MPMoviePlaybackStatePaused",
@"MPMoviePlaybackStateInterrupted",
@"MPMoviePlaybackStateSeekingForward",
@"MPMoviePlaybackStateSeekingBackward",
nil];
Btw that was only about the compiler warning, nothing else! If you want to know how to use static variables, please check "Local Static Variable Lifetime Expectation in Objective-C".
No comments:
Post a Comment