0

I have a general question, I want to hide the button from another class, that class is a wrapper class to mix c++ code and objective c code. I have a function say for ex: do action{}, that function will show some buttons and hide some other button depends on input. If I call the function in same class it is working fine. However if I call from wrapper class that is not working as expected.

when a buttons clicked I tried changing the state of the button by calling function like this. It worked.

main_class.mm
- (IBAction)switchViews:(id)sender
{
    [self doaction:5];
}

-(void) doaction:user_id
{
    self.email_id.hidden = YES;
}


@interface interface_wrapper : NSObject
{

@public
    rootViewController *root_view;

}

-(void) doaction:(long)user_id;

@end


@implementation gui_interface_wrapper

-(void) success:(long) user_id
{
         // root_view is set with root controller object. So that I can access main which is  having the button.

        [root_view.main doaction:user_id];

}

@end However if I have not called the function in that place. And a function call is made from some wrapper class outside it is having a pointer to that object [I checked self address is same in both the calls] button goes disabled instead of hiding. Can we do GUI action from wrapper class?

Any idea? thanks in advance.

Feroz
  • 699
  • 5
  • 17
  • 25
  • What are the relationships between the instance of the wrapper class and the instance of the class with buttons to be hidden? – user523234 Jul 25 '12 at 04:44
  • Wrapper class is having the pointer to that object which is having the button. – Feroz Jul 25 '12 at 04:58
  • A delegate pattern is probably what you need to use. An example is given here in here http://stackoverflow.com/questions/9629417/calling-a-method-from-another-class-in-objective-c/10898471#10898471 – user523234 Jul 25 '12 at 05:50
  • put code of the wrapper calss which calls this function – Mihir Mehta Jul 25 '12 at 06:10

1 Answers1

0

Are you creating another object of that class and call its method ? than it will not work.

class A
{
      object ofA;
}
//Code  In same class 

A a = init(); 
a.ofA = some value; 

//Code  In some other class
A anotherA = init(); 
anotherA.ofA = some other value; 

are you complainig that a's value doesn't change ? It will not because you are changing anotherA and expect to reflect in a... I hope it is your problem If not you should put some code

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
  • No I have a pointer of that object and using it in wrapper class. In my function self.email_id.hidden = YES; email_id is a text field it need to hidden. I check the address of self in both the calls both are same showing same address. when i do this email id goes disabled I'm not able to click that. there is some action happening but not clear. – Feroz Jul 25 '12 at 04:49