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:

  1. your control doesn’t have cell
    in case should create subclass of nsactioncell implement control. subclass of nscontrol shouldn’t besides setting cell.
    if don’t want right way using nscell you’ll have add instance variables nscontrol subclass store target , action , override getters , setters use them.

  2. your cell not subclass of nsactioncell. regular nscell doesn’t store target either.
    if you’re using custom cell not subclass of nsactioncell change inherit nsactioncell instead of nscell. if cannot (for example because you’re subclassing nscell subclass cannot change) you’ll have add instance variables target , selector cell class , override it’s setters , getters.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -