Is there any way define a object in a method, call a method of another object, and in that method use the first object:
-(IBAction)method{
class * instance = [[class alloc] initWithValue:value];
[instance method];
}
The method defined in class.m file:
-(void) method {
instance.value = someOtherValue;
}
The simple solution is to pass it in as a parameter:
To avoid coupling the two classes together too tightly, however, it is common to use a protocol to define the semantics of the callback, and to separate the method-call from the specification of the callback handler by assigning a delegate first, then calling methods. It’s a bit involved, and I hope I have correctly covered all the details.