NSUserDefaults in Utility App

Discussion in 'iOS Development' started by Rockstarou812, Feb 27, 2009.

  1. Rockstarou812

    Rockstarou812 New Member

    Joined:
    Jan 17, 2009
    Messages:
    43
    Likes Received:
    0
    I got the NSUserDefaults to work, thank you chicken4eve and everyone else. Now I want to be able to have the labels display on the mainview, and have the text fields on the flipside view allowing you to type in them.

    Know what I mean? I don't know how to do this because I would have to create an outlet, but how can I make it for two xibs?

    Please help, thanks.
  2. ipodgreatmaster

    ipodgreatmaster Member

    Joined:
    Feb 20, 2008
    Messages:
    186
    Likes Received:
    0
    Device:
    4G iPod touch
    I have the same problem
  3. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Umm not sure exactly what you are asking. Could you explain in more detail? Also yay I got credit.
  4. Rockstarou812

    Rockstarou812 New Member

    Joined:
    Jan 17, 2009
    Messages:
    43
    Likes Received:
    0
    Okay picture this

    Please Register or Log in to view images



    You open the app for the first time, it doesn't really say anything except "Welcome guest"

    then you click the info button on the button right of the screen, the screen flips to the other side and you can see a text field where you can type your name. You type it in, save it, then when you open the app again it is displayed on the front of the app.

    Basically what I need is a way to combine the NSUserDefaults on two different xibs, the MainView and Flipsideview.

    Make sense?
  5. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Oh yes that's easy just import that flip side view header into your main view header, then when accessing it use self.flipsideview.prefs, try that it should work.
  6. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    :/ i wanted to do exactly this and also jamie i gave you the code and importing it didnt work for me i had alot of trouble with this and would love to know how to do it
  7. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    hey Jack nice spreading my name out there lol! (only joking it's fine) I can try again if you send it to me.
  8. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    NSUserDefaults are app global. There for your request is not to hard.

    Code:
    -(void)viewDidLoad{
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstOpen"] == nil){
    //alert sheet code
    [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"FirstOpen"];
    }
    
    Or you can do a check to see if they have typed in there name
    Code:
    -(void)viewDidLoad{
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"Name"] == nil){
    //go to view
    }
    
    Just a choppy example

Share This Page