0
votes

I have the following code in my application:DidFinishLaunchingWithOptions: where I attempt to set tab bar tint colour:

UIColor *colour = [UAColors getSeasonalColour];

self.tabBarController.tabBar.tintColor = colour;    // SIGABORT here
[colour release];

getSeasonalColours is:

+(UIColor *)getSeasonalColour {
    UIColor *seasonalColour = 0;

    if ( [UADates isSpring:[NSDate date]] )
        seasonalColour = [UIColor greenColor];
    else if ( [UADates isSummer:[NSDate date]] )
        seasonalColour = [UIColor blueColor];
    else if ( [UADates isAutumn:[NSDate date]] )
        seasonalColour = [UIColor orangeColor];
    else if ( [UADates isWinter:[NSDate date]] )
        seasonalColour = [UIColor redColor];
    else
        seasonalColour = [UIColor blackColor];

    return seasonalColour;
}

Right now UADates is only a stub that returns true for isWinter.

Why would this cause a crash? Using the same getSeasonalColours works perfectly fine when I set the tintColor on a navigation bar.

2
What happens if you replace colour in the offending line with [UIColor redColor]? This should help isolate the problem.PengOne

2 Answers

3
votes

Setting a tab bar's tint color is only available starting with iOS 5 (and thus will crash on iOS 4 and earlier), while navigation bar tint colors have been around since iPhone OS 2.0.

2
votes

[colour release] should not be there, since your colours are all autoreleased. Are you sure that isn't the line that is crashing?