objective c - NSControl subclass can't read the target? -
the following code:
- (void) settarget:(id)anobject { nslog(@"anobject: %@",anobject); [super settarget:anobject]; nslog(@"target: %@",[self target]); }
has output:
anobject: <dropzoneviewcontroller: 0x15dd5770> target: (null)
this in subclass of nscontrol. doing wrong?
what i'm trying achieve: have nscontrol accepts dragging objects. when dragging ends, i'd send control's action target. how control's action & target if above doesn't work?
nscontrol
doesn’t store it’s own target, it’s cell supposed do.
so there 2 reasons might fail:
your control doesn’t have cell
in case should create subclass ofnsactioncell
implement control. subclass ofnscontrol
shouldn’t besides setting cell.
if don’t want right way usingnscell
you’ll have add instance variablesnscontrol
subclass store target , action , override getters , setters use them.your cell not subclass of
nsactioncell
. regularnscell
doesn’t store target either.
if you’re using custom cell not subclass ofnsactioncell
change inheritnsactioncell
instead ofnscell
. if cannot (for example because you’re subclassingnscell
subclass cannot change) you’ll have add instance variables target , selector cell class , override it’s setters , getters.
Comments
Post a Comment