Must use “struct” tag to refer to type “label”

I got an error Must use 'struct' tag to refer to type 'label' What is not correct?? I marked by comments where error appears. My Xcode version is 5.0.2 /////////////////////////////////////////////////////////////////////////////////////////////// .m

  #import "GameViewController.h"

@interface GameViewController ()

@end

@implementation GameViewController

-(void)generate{
    int a=1+arc4random() % 9;
    int b=1+arc4random() % 9;

    int sum=a+b;
    label.text = [NSString stringWithFormat:@"%d + %d = ", a, b]; //here is error
    label.tag=sum;  //and here

}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self generate];
    // 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)submit:(id)sender {
    int num=[_answer.text intValue];
    UIAlertView *alert;
    if(num == _label.tag){
        alert=[[UIAlertView alloc]initWithTitle:@"Correct" message:@"Let's try another one!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        alert.tag =1;
    }else{
        alert =[[UIAlertView alloc]initWithTitle:@"Wrong!" message:@"That answer is incorrect" delegate:self cancelButtonTitle:@"Try again" otherButtonTitles:nil, nil];
    }
    [alert show];
}

@end

.h

#import <UIKit/UIKit.h>

@interface GameViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *answer;

- (IBAction)submit:(id)sender;
@end

Answers


Try self.label.text or _label.text


Need Your Help

Create an all-day event using Google Calendar API

c# .net google-calendar

Iam working with C# and the Google Calendar API classes "CalendarService" and "Event".

JavaScript object element is missing during Mongoose update query

javascript angularjs node.js mongodb mongoose

I'm trying to update a new field of data into an existed document, but some of the data is not updating.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.