Results 1 to 2 of 2

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.

Thread: Creating a Singleton

  1. #1
    Default Creating 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

  2. #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; 2011-07-31 at 06:27 PM.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts