ios - Setting BOOL to "YES" in custom delegate -
i've make delegate 2 different view controllers can communicate , i'm stuck trying set bool yes in child view controller.
childviewcontroller.h
@protocol pagetwoviewcontrollerdelegate; @interface pagetwoviewcontroller : uiviewcontroller { uibutton *takephototransition; } @property (nonatomic, weak) id<pagetwoviewcontrollerdelegate> delegate; @end @protocol pagetwoviewcontrollerdelegate <nsobject> - (bool)didpushtakephoto; @end
childviewcontroller.m
... - (ibaction)takephototransition:(id)sender { id<pagetwoviewcontrollerdelegate> strongdelegate = self.delegate; if ([strongdelegate respondstoselector:@selector(didpushtakephoto)]) { strongdelegate.didpushtakephoto = yes; // error: no setter method 'setdidpushtakephoto:' assignment property } nslog(@"button push recieved"); }
how can past error , set bool yes when button pushed?
you getting confused between method , property.
the definition of protocol "pagetwoviewcontrollerdelegate", says should implement method name "didpushtakephoto" returns bool value.
what trying entirely different. trying set non-existent property. whenever accessing followed dot ".", should property of class object belongs. protocol defined not talk property.
so inside if condition, should calling method "didpushtakephoto" on delegate object, below. [strongdelegate performselector:@selector(didpushtakephoto)];
if know sure delegate implementations have protocol method implemented, since cast self.delegate strongdelegate declared id, don't need if condition. directly call method below. [strongdelegate didpushtakephoto];
hope helps
Comments
Post a Comment