简体   繁体   中英

IOS call parent class method from subclass

I am developing iPadd application. I use parent class for list and also use sub class for category selection. Subclass opening in popover. If user select any category from sub class then parent screen refresh with refreshScreenForiPad. So I want to call parentClass method What is refreshScreenForiPad. But i did not call. Please help me.

//ParentClass.h

#import <UIKit/UIKit.h>
#import SubClass;

@interface ParentClass : UIViewController{

}
-(void)refreshScreenForiPad;

---------------------


//SubClass.h

#import <UIKit/UIKit.h>
@class ParentClass;

@interface SubClass : UIViewController{
ParentClass *_parentClass;
}

@property(nonatomic,assign) ParentClass *parentClass;



//SubClass.m

@synthesize parentClass=_parentClass;

-(void)viewDidLoad{
 [self.parentClass refreshScreenForiPad];
}

in the parentClass when the subClass is initialized..say

SubClass *subClass = [[SubClass alloc]init];

follow it with

sublass._parentClass = self;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM