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 ofnsactioncellimplement control. subclass ofnscontrolshouldn’t besides setting cell.
if don’t want right way usingnscellyou’ll have add instance variablesnscontrolsubclass store target , action , override getters , setters use them.your cell not subclass of
nsactioncell. regularnscelldoesn’t store target either.
if you’re using custom cell not subclass ofnsactioncellchange inheritnsactioncellinstead ofnscell. if cannot (for example because you’re subclassingnscellsubclass cannot change) you’ll have add instance variables target , selector cell class , override it’s setters , getters.
Comments
Post a Comment