Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.
Thread: Creating a Singletonis a discussion within the
iPhone / iPod Touch SDK | Development Discussionforums, a part of the
3rd Party Apps For iPhone | iPod Touchsection;
I have been searching for a while now trying to get the basic idea of a singleton and how to implement one. I basically understand the use of them and...
07-26-2011, 04:01 PM #1Creating a Singleton
I have been searching for a while now trying to get the basic idea of a singleton and how to implement one. I basically understand the use of them and how they can work like global variables, however, I have yet to come across someone who really breaks down the writing and implementation of one. For example if I wanted to pass a string from a uitextfield in one view to a uilabel in another view, how would I go about doing this?RIP Steve Jobs.. You changed the world
07-31-2011, 11:24 AM #2
I dont know anything about a singleton but what you could do is create a static variable in the header of your code and call it later on. For example:
//this should appear right after any #import's on the top of your code
static NSString *textFieldString=nil;
//then take the UITextField's text and make that the textFieldString
textFieldString = "Name of UITextField".text;
//when ever you implement UILabel run this
"Name of UILabel".text = textFieldString;
that should do the trick.
Last edited by william_vab; 07-31-2011 at 11:27 AM.