ios – App crashes with EXC_BREAKPOINT on assigning border colour of UICollectionViewCell

[ad_1]

I’ve code that flashes the border of a cell in a group view by altering its colour at set intervals. When the flash sequence begins, the unique colour of the cell is saved, in order that when the flash sequence is full, the colour could be restored. The crash that happens does not clarify precisely what’s incorrect, so I am left making an attempt to infer the issue, and what I am seeing within the debugger is not making a lot sense.

Word that that is code that previously has been examined to work with out crashing, undecided why it is instantly failing now.

The error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1831e1fd4) (The road seems in pink and execution won’t proceed, so no this isn’t simply stopping at a breakpoint, it’s a crash.)

The code…

@interface OrderCollectionViewCell : UICollectionViewCell 

               .   .   .

@property (sturdy, nonatomic) NSTimer *borderTimer;
@property (nonatomic) BOOL blinkStatus;
@property (nonatomic) NSInteger blinkTimes;

               .   .   .

@implementation OrderCollectionViewCell
{
    CGColorRef normalBorder;
}

-(void)flashBorder
{
    // Save authentic colour for later restore
    normalBorder = self.bg.layer.borderColor;
    
    if(self.borderTimer) {
        [self.borderTimer invalidate];
    }
    self.borderTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(blink) userInfo:nil repeats:YES];
    
    [[NSRunLoop mainRunLoop] addTimer:self.borderTimer forMode:NSRunLoopCommonModes];
    
    self.blinkTimes = 0;
    self.blinkStatus = NO;
}


-(void)blink
{
    if (self.blinkTimes++ == 3)
    {
        // Sequence full.  Restore authentic colour
        self.bg.layer.borderColor = normalBorder;  // <-- This line crashes
        [self.borderTimer invalidate];
        self.borderTimer = nil;
        return;
    }
    
    if(self.blinkStatus == NO){
        self.bg.layer.borderColor = [UIColor whiteColor].CGColor;
        self.blinkStatus = YES;
    }else {
        self.bg.layer.borderColor = [UIColor orangeColor].CGColor;
        self.blinkStatus = NO;
    }
}

This is the place issues get bizarre. Based on the docs, CGColorRef is a struct, not an object. I set a breakpoint in flashBorder, and verify the worth of self.bg.layer.borderColor and variable normalBorder after copying the colour to it.

enter image description here

Word that the handle of every is reported as <CGColor 0x281b6d200>, which is extra like object conduct than struct conduct.

When the time comes to revive the colour, the variable normalBorder now not seems to comprise legitimate colour knowledge, because it’s merely reported as an handle (the identical handle as earlier than) however no descriptive output:

enter image description here

Does anybody know what is perhaps inflicting this failure, or why within the debugger the CGColorRef appears to be performing like an object moderately than a struct?

[ad_2]

Leave a Reply