Passing int from one Function to another

Discussion in 'iOS Programming' started by spire.bt, Sep 22, 2010.

  1. spire.bt macrumors newbie

    Joined:
    Apr 8, 2010
    #1
    I really have no idea how this is done, it should be simple but i just cant get it

    i have an IBAction and void and want to do this:


    Code:
    -(IBAction)pass{
    int VariableX = 10;
    
    [B][self getVar]; ---> send var to -(void)getVar[/B]
    }
    
    
    -(void)getVar{
    
    [B]get the VariableX[/B]
    
    if(VariableX=10){
    do something
    }
    }
    
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Sometimes code is faster than explaining!

    Code:
    -(IBAction)pass{
    int VariableX = 10;
    
    [self getVar:VariableX ];
    }
    
    
    -(void)getVar:(int) var
    {
    
    if(var=10){
    do something
    }
    
     
  3. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #3
    You might want to consider getting a beginners book on Objective-C if you don't know how to do this before you go any further.
     

Share This Page