Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.
Thread: Creating a Singleton
07-26-2011, 03: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, 10: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 10:27 AM.