I am in the process of reading the O’Reilly book Learning Cocoa with Objective-C 3rd edition.
The O’Reilly website doesn’t have a forum for this specific book, and searching for this error returns nothing.
On page 18, I keep getting the following error:
"No visible @interface for 'UIAlertView' declares the selector 'initWithTitle:message:deluge:cancelButtonTitle:otherButton'"
Here’s my code:
//
// ViewController.m
// HelloCocoa
//
// Created by ME on 1/14/13.
// Copyright (c) 2013 ME. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showAlert:(id)sender
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Hello!"
message:@"Hello, World!"
delegate:nil
cancelButtonTitle:@"Close"
otherButtonTitle:nil];
[alert show];
[_helloButton setTitle:@"I was Clicked!" forState:UIControlStateNormal];
}
@end
//
// ViewController.h
// HelloCocoa
//
// Created by ME on 1/14/13.
// Copyright (c) 2013 Andrew DiNatale. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *helloButton;
- (IBAction)showAlert:(id)sender;
@end
What’s causing this error?
The
otherButtonTitlesparameter is plural (as inotherButtonTitle*s*).