NGLocanovic
Neues Mitglied
Thread Starter
- Dabei seit
- 09.09.2013
- Beiträge
- 5
- Reaktionspunkte
- 0
Zu allererst "Hallo" an die MacUser-Community!
Ich habe erst seit kurzem einen Mac und will langsam in der Mac/iOS-Programmierung einsteigen.
Jetzt stellt sich mir ein (bestimmt) sehr simples Problem in den Weg.
Meine "App" habe ich aufs wesentliche reduziert, um es leicht verständlich zu machen.
Mein Vorhaben:
Ich möchte mit dem TextField (und dem Button) der "SecondViewController"-Klasse das Label der "FirstViewController"-Klasse ändern. Ich habe Verschiedenstes probiert - Ergebnis immer ernüchternd. Meine Vermutung ist, dass die FirstViewController-Klasse nicht die Berechtigung hat das Textfeld auszulesen
Dies ist mein letzter Versuch gewesen:
Ich hoffe auf positive Antwort und entschuldige mich schonmal vorab falls es das Thema schon dutzendfach gibt. Ich wusste einfach nicht welches Schlagwort mein Problem beschreibt :/
Viele Grüße
NG_Locanovic
Ich habe erst seit kurzem einen Mac und will langsam in der Mac/iOS-Programmierung einsteigen.
Jetzt stellt sich mir ein (bestimmt) sehr simples Problem in den Weg.
Meine "App" habe ich aufs wesentliche reduziert, um es leicht verständlich zu machen.
Mein Vorhaben:
Ich möchte mit dem TextField (und dem Button) der "SecondViewController"-Klasse das Label der "FirstViewController"-Klasse ändern. Ich habe Verschiedenstes probiert - Ergebnis immer ernüchternd. Meine Vermutung ist, dass die FirstViewController-Klasse nicht die Berechtigung hat das Textfeld auszulesen
Dies ist mein letzter Versuch gewesen:
Code:
FirstViewController.h
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]<UIKit/UIKit.h>[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[FONT=Menlo][COLOR=#bb2ca2]@interface[/COLOR] FirstViewController : [COLOR=#703daa]UIViewController[/COLOR][/FONT]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]weak[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UILabel[/COLOR][COLOR=#000000] *label;[/COLOR][/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
Code:
FirstViewController.m
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]"FirstViewController.h"[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#4F8187][FONT=Menlo][COLOR=#bb2ca2]@interface[/COLOR]FirstViewController[COLOR=#000000] ()[/COLOR][/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[FONT=Menlo][COLOR=#bb2ca2]@implementation[/COLOR] FirstViewController[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])viewDidLoad[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]super[/COLOR]viewDidLoad[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#008400][FONT=Menlo]// Do any additional setup after loading the view, typically from a nib.[/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])didReceiveMemoryWarning[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]super[/COLOR]didReceiveMemoryWarning[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#008400][FONT=Menlo]// Dispose of any resources that can be recreated.[/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
Code:
SecondViewController.h
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]<UIKit/UIKit.h>[/FONT][/COLOR]
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]"FirstViewController.h"[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#703DAA][FONT=Menlo][COLOR=#bb2ca2]@interface[/COLOR][COLOR=#000000] SecondViewController : [/COLOR]UIViewController[COLOR=#000000] <[/COLOR]UITextFieldDelegate[COLOR=#000000]>[/COLOR][/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]weak[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UITextField[/COLOR][COLOR=#000000] *TextField;[/COLOR][/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])Button:([COLOR=#703daa]UIButton[/COLOR] *)sender;[/FONT]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
Code:
SecondViewController.m
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]"SecondViewController.h"[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#4F8187][FONT=Menlo][COLOR=#bb2ca2]@interface[/COLOR]SecondViewController[COLOR=#000000] ()[/COLOR][/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
[FONT=Menlo]
[/FONT]
[FONT=Menlo][COLOR=#bb2ca2]@implementation[/COLOR] SecondViewController[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])viewDidLoad[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]super[/COLOR]viewDidLoad[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#008400][FONT=Menlo]// Do any additional setup after loading the view, typically from a nib.[/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])didReceiveMemoryWarning[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]super[/COLOR]didReceiveMemoryWarning[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#008400][FONT=Menlo]// Dispose of any resources that can be recreated.[/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]-([COLOR=#bb2ca2]BOOL[/COLOR])textFieldShouldReturn:([COLOR=#703daa]UITextField[/COLOR] *)textField[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [textField [/COLOR]resignFirstResponder[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#BB2CA2][FONT=Menlo]returnYES[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])Button:([COLOR=#703daa]UIButton[/COLOR] *)sender {[/FONT]
[COLOR=#4F8187][FONT=Menlo]FirstViewController[COLOR=#000000] *firstView = [[[/COLOR]FirstViewController[COLOR=#3d1d81]alloc[/COLOR][COLOR=#000000]] [/COLOR][COLOR=#3d1d81]init[/COLOR][COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] firstView.[COLOR=#4f8187]label[/COLOR].[COLOR=#703daa]text[/COLOR] = [COLOR=#bb2ca2]self[/COLOR].[COLOR=#4f8187]TextField[/COLOR].[COLOR=#703daa]text[/COLOR];[/FONT]
[FONT=Menlo]}[/FONT]
Ich hoffe auf positive Antwort und entschuldige mich schonmal vorab falls es das Thema schon dutzendfach gibt. Ich wusste einfach nicht welches Schlagwort mein Problem beschreibt :/
Viele Grüße
NG_Locanovic