在为iPhone做app时,我的Xcode编译器出现了一个奇怪的错误。我得到的错误是:
Expected ']'
- (IBAction)backButton:(id)sender
{
NSUserDefaults* standardUserDefaults = [NSUserDefaults standardUserDefaults];
if(standardUserDefaults)
{
NSString* isNewNote = [standardUserDefaults objectForKey:@"newNote"]; // here is the error
if(isNewNote isEqualToString:@"Yes")
{
[noteList removeObjectAtIndex:currentNote];
[noteContent removeObjectAtIndex:currentNote];
}
}
NSString* storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[self presentViewController:vc animated:NO completion:nil];
}
你能搞清楚什么是错的吗?感谢。
答案 0 :(得分:3)
此:
if(isNewNote isEqualToString:@"Yes")
应该是这样的:
if([isNewNote isEqualToString:@"Yes"])