+ Reply
Results 1 to 2 of 2

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


Thread: Creating a Singleton

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
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
...
  1. #1
    iPhone? More like MyPhone sammo123's Avatar
    Join Date
    Dec 2007
    Posts
    152
    Thanks
    12
    Thanked 36 Times in 9 Posts

    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
    What's Jailbreak? william_vab's Avatar
    Join Date
    Feb 2010
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post
    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.

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