objective c - iPhone SDK: Can I nab in instance variable from one view and access it in another? -


i'm pretty new oop in general , started working obj-c few months back. so, please gentle! appreciate in advance. question!

i have 3 text fields user inputs name, phone, , email.

i collect , place them in label using nsstring [this 1 name]:

- (ibaction)changegreeting:(id)sender { self.name = textinput.text;  nsstring *namestring = name; if([namestring length] == 0) {     namestring = @"i forgot"; } nsstring *greeting = [[nsstring alloc]                        initwithformat:@"hello, name %@! really!", namestring]; label.text = greeting; [greeting release]; }  

with have been able place text text.input label (as stated in label.text = greeting;)

i have view i'd have review information (view label too). need have access name or textinput.text in other view.

how can accomplish this?

if don't need communicate changes between 2 view controllers, may want pass in using custom init method. may best confirmation screen, prompt make no sense without string.

- (id)initwithframe:(cgrect)arect username:(nsstring*)aname {     if((self = [super initwithframe:arect])) {         _myname = [aname retain];     }     return self } 

another option implement method on first view controller , call second.

- (nsstring*)enteredusername {     return _myname; } 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -