objective c - passing data from parent to child -


in app i'm trying pass data parent view child view. however, when run app delegate method isn't being called. here code on how implemented custom delegate: parent.h

    @protocol slbwallviewcontrollerdelegate <nsobject>  - (void) picturetobeuploaded:(id)picture;  @end  @interface slbwallviewcontroller : uiviewcontroller <uiactionsheetdelegate, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate> - (ibaction)createpotbuttonpressed:(id)sender;  @property (weak, nonatomic) id <slbwallviewcontrollerdelegate> delegate; @end 

parent.m

[self.delegate picturetobeuploaded:info[uiimagepickercontrollereditedimage]];//i'm taking pic uiimagepicker 

child.h

@interface slbpostviewcontroller : uiviewcontroller <slbwallviewcontrollerdelegate> @property (weak, nonatomic) iboutlet uiimageview *picture; @end 

child.m

#pragma mark - wall view controller delegate - (void)picturetobeuploaded:(id)picture{     self.picture.image = picture; } 

is there wrong or missing?

well, problem (edit: confirmed in comments) self.delegate nil @ point. send message nil , nothing happens of course. have make sure assign child instance delegate property before trying send message. example:

//... self.delegate = //.. 'child' instance  //... [self.delegate picturetobeuploaded:info[uiimagepickercontrollereditedimage]]; 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -