xcode - Properties of CALayer in layer-backed view won't display, and variable losing value in cocoa app -


i have collection view containing objects (cards) bound core data entity. each of cards has type attribute gets set user input when card added. class of collection view item prototype subclass of nsview synthesized property "cardtype". i've managed synced item represented. in interfacebuilder, prototype view connected outlet arraycontroller (*view).

what's been elusive far want cards in collection view have different colored backgrounds dependent on type. i've been trying work calling following method array controller's - (id)newobject method:

-(void)settypeofcardview { nslog(@"card type %@",cardtype); if(self.layer && [self.cardtype isequal:@"opening"]) {     nslog(@"yes layer , card type test");     [self.layer setdelegate:self];     nslog(@"borderwidth %f",self.layer.borderwidth);     self.layer.backgroundcolor = [nscolor bluecolor].cgcolor;     self.layer.bordercolor = [nscolor blackcolor].cgcolor;     self.layer.borderwidth = 6.0;     nslog(@"borderwidth %f",self.layer.borderwidth);     self.layer.cornerradius = 5;     [self.layer setneedsdisplay]; } } 

feedback console method called, cardtype property set correctly,and when user input adding card "opening" type called, goes through , seems change appropriate calayer properties. (logs different attributes beginning , end of method) life of me can't show on screen, though.

i've tried [self drawrect:self.bounds];, without `setneedsdisplay', without of them, of them, etc, couldn't change on screen.

i tried direction of putting if block in view's `drawrect:' method, this:

- (void)drawrect:(nsrect)dirtyrect {     //first test layer     if (self.layer){         nslog(@"layer test");         self.layer.cornerradius = 5;            nslog(@"card type is:%@",self.cardtype);          //begins nested cardtype string comparison test         nsstring *label = @"opening";         if ([self.cardtype isequal:label])         {             nslog(@"passed cardtype string comparison test");             self.layer.backgroundcolor = [nscolor bluecolor].cgcolor;         } } nslog(@"drawing card");     self.layer.bordercolor = [nscolor blackcolor].cgcolor;     self.layer.borderwidth = 6.0;     self.layer.cornerradius = 5; 

}

i can't work either, different reasons. can layer properties change, can't string comparison test work, , when log cardtype value console, (null), instead of proper string. result code above cards corner radius outer if block, border properties lower (outside if blocks), can't backgroundcolor property inner nested if block. unfortunately, that's need of be.

as seems problem cardtype declaration, (or retaining value?) i've included header file class here:

#import <cocoa/cocoa.h> #import <quartzcore/quartzcore.h>  @interface sdcardview : nsview{ }  @property (strong) nsstring *cardtype;  -(void)settypeofcardview;   @end   

i'm @ wits end here, if throw me bone, i'd appreciate it!


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -