iphone - ios Calling back viewController from different class -
i have problems calling viewcontroller nsobject class. here code:
viewcontroller:
-(void)starttest:(nsstring*)testtorun { viewcontroller *viewcontroller = [[[viewcontroller alloc] init] autorelease]; secondclass *secondclass = [[secondclass alloc] init]; secondclass.viewcontroller = viewcontroller; [secondclass dosomething]; } -(void) createview { uiview *newview = [uiview alloc] initwithframe:[self.view bounds]; self.newview.backgroundcolor = [uicolor whitecolor]; [self.view addsubview:newview]; [self.view bringsubviewtofront:newview] } nsobject classe: .h file #import "viewcontroller.h" @class viewcontroller; @interface secondclass : nsobject { viewcontroller *viewcontroller; } @property (nonatomic,retain) viewcontroller *viewcontroller; -(void) dosomething; .m file -(void) dosomething { [viewcontroller createview]; }
any of may know i'm doing wrong or how can call view controller nsobject class?
you're referring instance variable viewcontroller
assigning property viewcontroller
.
the property automatically synthesized instance variable called _viewcontroller
default. can change explicitly synthesize instance variable, more canonical thing use default _viewcontroller
, refer self.viewcontroller
within implementation file.
Comments
Post a Comment