views:

47

answers:

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:

   -(IBAction)pass{
int VariableX = 10;
[self getVar]; ---> send var to -(void)getVar

}


-(void)getVar{

get the VariableX

if(VariableX=10){
do something
}
}
+1  A: 

declare getVar function to get one (integer) parameter:

// header
-(void)getVar:(int)varX;

// implementation
-(void)getVar:(int)varX{
   if (varX == 10)
      // do something
}

Then call it the following way:

-(IBAction)pass{
   int VariableX = 10;
   [self getVar:VariableX];
}

Generally the syntax of method declaration in objective-c is:

- (ReturnType) functionName:(1st parameter type)1stParameterName 
               2ndParameter:(2nd parameter type)2ndParameterName
               etc
Vladimir
This is most essential and basic knowledge however, I strongly suggest looking into some beginners Objective C tutorials...
Toastor
I appreciate your advice Toastor but I was asking for some guidance because sometimes people like Vladimir are more experienced and can explain things for easier comprehension. Vladimir thanks a lot
Spire