我在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」。)這解釋了你的第二個錯誤信息。 –