Problems understanding how to link IBActions with storyboard

Discussion in 'iOS Programming' started by scrace89, Nov 23, 2011.

  1. macrumors member

    Joined:
    Sep 2, 2010
    #1
    I tried to follow a tutorial made before storyboard and I tried to link my buttons to IBActions as follows

    control + click to the IBAction method.

    Now when I click any of the buttons I get 0 or a huge int but never does what is should do and I don't understand why. I followed a basic tutorial on youtube. I'm a beginner programmer to objective-c and using Xcode 4.2 which is most of the problem but if anyone could help me out this is I would appreciate it.

    [​IMG]
    [​IMG]
    [​IMG]

    Any good free guides or tutorials to help me understand IBActions and anything IU related using the interface?
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    I don't know how Storyboards work but.
    IBActions, I can explain that to you though.

    IBActions, simply means "Interface Builder Actions", this will provide a VOID method, because IBAction is simply a void method but with another name.
    The tool where you define the interface is called Interface Builder, just got integrated in the IDE since Xcode 4.
    So what it basicly does is, just tell the button to call an action you provide, and you can only hook it via IB (Interface Builder), if it's an IBAction, or if your button is a IBOutlet (Interface builder outlet), and you attach it via code.

    None the less, you are adding an (id)sender to 1 method, but not to the rest, do you know what it does?

    Also, I see you defining your integer above your interface, this is NOT recommanded
    when you want to make ivars, avaible in your class.

    Code:
     @interface ViewController:UIViewController {
     NSInteger anInt;
    } 
    
    @property's go here
    
    - methods go here
    
    It's some basic Objective C things/Xcode things, you should maybe just read through some books.. I think it will help you more then just posting stuff on forums and waiting for people like me to answer.
     
  3. macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #3
    One thing I notice is that your lines;
    Code:
    number.text = [NSString stringWithFormat:@"%i"];
    are missing the value you want to display.

    It should be;
    Code:
    number.text = [NSString stringWithFormat:@"%i", count];
     
  4. thread starter macrumors member

    Joined:
    Sep 2, 2010
    #4
    I have a good Xcode book, but not an xCode book. I've worked my way through half of Kochan's book and am bored with not getting to use the interface builders, I also have the big nerd ranch guide which I am going to crack open and start. I learn better by doing this that are too complex and asking question as well as reading. I just couldn't figure this out for some reason and it was so obvious once xStep said something.

    I made the getter and setter methods for count by property and synthesizing it.

    thank you so much, I'm an idiot.
     

Share This Page