- Registriert
- 20.06.12
- Beiträge
- 132
Also ich versuche gerade ein bisschen Objective-C zu lernen und Xcode zu nutzen.
Ich habe nun die
xjyViewController.m
xjyViewController.h
Nur leider passiert nichts wenn ich den Button drücke (im interfacebuilder ist soviel ich weiss alles verbunden tempText, resultLabel und die IBAction).
Ich habe nun die
xjyViewController.m
Code:
- ([COLOR=#0433FF]void[/COLOR]) convertTemp: ([COLOR=#0433FF]id[/COLOR]) sender {[COLOR=#3495AF][COLOR=#000000] [/COLOR][COLOR=#0433ff]double[/COLOR][COLOR=#000000] farenheit = [[/COLOR]tempText[COLOR=#000000].[/COLOR]text[COLOR=#000000] [/COLOR]doubleValue[COLOR=#000000]];[/COLOR][/COLOR]
[COLOR=#0433ff]double[/COLOR] celsius = (farenheit - 32) / 1.8;
[COLOR=#3495af]NSString[/COLOR] *resultString = [[[COLOR=#3495af]NSString[/COLOR] [COLOR=#3495af]alloc[/COLOR]] [COLOR=#3495af]initWithFormat[/COLOR]:[COLOR=#b4261a]@"Celsius %f"[/COLOR], celsius];
[COLOR=#3495af]resultLabel[/COLOR].[COLOR=#3495af]text[/COLOR] = resultString;
}
- ([COLOR=#0433ff]void[/COLOR]) viewDidUnload{
[COLOR=#3495AF][COLOR=#000000] [/COLOR][COLOR=#0433ff]self[/COLOR][COLOR=#000000].[/COLOR]resultLabel[COLOR=#000000] = [/COLOR][COLOR=#0433ff]nil[/COLOR][COLOR=#000000];[/COLOR][/COLOR]
[COLOR=#0433ff]self[/COLOR].[COLOR=#3495af]tempText[/COLOR] = [COLOR=#0433ff]nil[/COLOR];
}
Code:
[COLOR=#0433FF]@interface[/COLOR] xjyViewController : [COLOR=#3495AF]UIViewController[/COLOR] { [COLOR=#3495af]UITextField[/COLOR] *tempText;
[COLOR=#3495af]UILabel[/COLOR] *resultLabel;
}
[COLOR=#0433FF]@property[COLOR=#000000] ([/COLOR]nonatomic[COLOR=#000000], [/COLOR]retain[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#000000] [/COLOR][COLOR=#3495af]UILabel[/COLOR][COLOR=#000000] *resultLabel;[/COLOR][/COLOR]
[COLOR=#0433FF]@property[COLOR=#000000] ([/COLOR]nonatomic[COLOR=#000000], [/COLOR]retain[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#000000] [/COLOR][COLOR=#3495af]UITextField[/COLOR][COLOR=#000000] *tempText;
[/COLOR][/COLOR]
- ([COLOR=#0433FF]IBAction[/COLOR])convertTemp:([COLOR=#0433FF]id[/COLOR])sender;
Nur leider passiert nichts wenn ich den Button drücke (im interfacebuilder ist soviel ich weiss alles verbunden tempText, resultLabel und die IBAction).