ios - How can I use methods defined in this delegate? -
i'm new ios development, , i'm playing interface trying understand concepts. provided sdk(which compiled , can't it) has following definitions:
@class hrmonitor; @protocol hrmonitordelegate - (void) hrmon: (hrmonitor*) mon heartrateupdate: (double) hr; // , others @end @interface hrmonitor : nsobject <nsstreamdelegate>{ } -(id) init: (id) _delegate; -(void)startup;
does have idea how can use heartrateupdate
method defined in protocol hrmonitordelegate
? read in ios developer library, have have interface conforms delegate hrmonitor : nsobject <hrmonitordelegate>
call methods in protocol. that's not provided in api.
or can use init
method? how should pass _delegate
?
conform interface delegate
init hrmonitor, passing interface instance _delegate
then - (void) hrmon: (hrmonitor*) mon heartrateupdate: (double) hr of interface called
make interface conforms delegate, , call method of when need, remember check delegate not nil , response method want call
@interface yourclass : nsobject <hrmonitordelegate> @implementation hrmonitor -(void)somemethod { hrmonitor monitor = [hrmonitor alloc] init:self]; } - (void) hrmon: (hrmonitor*) mon heartrateupdate: (double) { }
Comments
Post a Comment