Ciao ragazzi, qualcuno sa spiegarmi perché non appena nella "class ViewController: UIViewController" dichiaro "@IBOutletvar nLable : UILabel" mi dice che la classe non è inizializzata? Grazie
Ciao ragazzi, qualcuno sa spiegarmi perché non appena nella "class ViewController: UIViewController" dichiaro "@IBOutletvar nLable : UILabel" mi dice che la classe non è inizializzata? Grazie
detto così è difficile aiutarti... magari se posti l'intero file
import UIKit
class ViewController: UIViewController {
@IBOutlet var nLabel: UILabel
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func numero(button : UIButton){
if nLabel.text == "0" {
nLable.text = button.titleLabel.text
}else{
nLable.text = nLable + button.titleLabel.text
}
}
}
Dopo che scrivo questo "@IBOutlet var nLabel: UILabel" mi dice che la classe non è inizializzata! Grazie mille per l'aiuto! Non so se fa la differenza, ma uso Xcode versione 6.1
Non so se possa esserti d'aiuto la stessa cosa scritta in objc... purtroppo non ho esperienza in swift... comunque stai attento che hai scritto nLable al posto di nLabel
NEL FILE .H
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutletUILabel *nLabel;
- (IBAction)numeroid)sender;
@property (weak, nonatomic) IBOutletUIButton *button;
@end
NEL FILE .M
#import "ViewController.h"
@interfaceViewController ()
@end
@implementation ViewController
@synthesize nLabel,button;
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)numeroid)sender {
if ( [nLabel.textisEqualToString:@"0"] )
{
nLabel.text = button.titleLabel.text;
}else{
nLabel.text = [NSStringstringWithFormat:@"%@%@", nLabel.text, button.titleLabel.text];
}
}
Ti ringrazio, davvero gentile!![]()