我在iPhone开发总初学者,所以我有一个小问题:无法访问标签
这是我viewcontroller.m
//
// ViewController.m
// Conversie talstelsels
//
// Created by Stijn Hoste on 16/11/12.
// Copyright (c) 2012 Stijn Hoste. All rights reserved.
//
#import "ViewController.h"
@interface ViewController()
@synthesize lblOct;
@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)txtGetal:(id)sender {
lblOct.text = @"derp";
}
@end
这是我viewcontroller.h
//
// ViewController.h
// Conversie talstelsels
//
// Created by Stijn Hoste on 16/11/12.
// Copyright (c) 2012 Stijn Hoste. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction)txtGetal:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *lblDec;
@property (weak, nonatomic) IBOutlet UILabel *lblOct;
@property (weak, nonatomic) IBOutlet UILabel *lblHex;
@end
所以当我尝试这样做:@synthesize lblOct; 它给了我以下错误:非法界面限定符 当我尝试这样做:lblOct.text = @“derp”; 它给了我这个错误:使用未声明的标识符'lblOct',你的意思是'_lblOct'吗?
有人可以帮我解决这个问题吗?
在此先感谢!
你不应该在界面中“@综合”一个属性 - 将其移入实现中。 – 2012-11-16 22:13:20
将'@ synthesize'移入'@ implementation'。 –
当你没有'@ synthesize'时,最新的Xcode会提供一个,但它会将你的“xxxx”属性与实例变量“_xxxx”关联起来。 (而@synthesize xxxx;'关联属性“xxxx”与实例变量“xxxx”。)这解释了你的第二个错误信息。 –