Undeclared identifier in UIAlertView

Discussion in 'iOS Programming' started by Kapthehat, Sep 2, 2013.

  1. Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    Hello,

    I am having a problem with the following piece of code (I am a newbie and just experimenting - so it is nothing complicated). I get an "expected identifier error" on each of the lines in red below. Can somebody help me please ? thanks

    regards

    Kaps

    Code:
    
    //
    //  BIDViewController.m
    //  Calctest
    //
    //  Created by Kapil Kapur on 02/09/2013.
    //  Copyright (c) 2013 Apress. All rights reserved.
    //
    
    #import "BIDViewController.h"
    
    @interface BIDViewController ()
    
    @end
    
    @implementation BIDViewController
    
    - (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)buttonOnePressed
    {
      [COLOR="red"][B][I]  UIAlertView *alert1 = [[UIAlertView] alloc   initWithTitle:@"Calculator test"[/I][/B][/COLOR]
                                                          message:@"You pressed ONE"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                 otherButtonTitle:nil];
        
        [alert1 show];
    }
    
    -(IBAction)buttonTwoPressed
    {
        
       [COLOR="red"][I] UIAlertView *alert2 = [[UIAlertView] alloc   initWithTitle:@"Calculator test"[/I][/COLOR]
                                                          message:@"You pressed TWO"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                 otherButtonTitle:nil];
        
        [alert2 show];
    
        
        
    }
    
    -(IBAction)ButtonThreePressed
    {
        [I][COLOR="Red"]UIAlertView *alert3 = [[UIAlertView] alloc   initWithTitle:@"Calculator test"
         [/COLOR][/I]                                                  message:@"You pressed THREE"
                                                          delegate:nil
                                                 cancelButtonTitle:@"OK"
                                                  otherButtonTitle:nil];
        
        [alert3 show];
        
        
        
        
    }
    @end
    
    
     
  2. Sonnestah macrumors regular

    Joined:
    Mar 2, 2013
    #2
    Yes, you've got two problems:

    - it is [UIAlertView alloc] and not [UIAlertView] alloc
    - it is otherButtonTitles and not otherButtonTitle


    Code:

    Code:
        UIAlertView *alert1 = [[UIAlertView alloc]   initWithTitle:@"Calculator test"
                                                           message:@"You pressed ONE"
                                                          delegate:nil
                                                 cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013

Share This Page