I included a header in my prefix.pch file as so:
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Constants.h"
#endif
And in the included header is a class extensions:
@interface UIColor (MyApp)
+(UIColor *) myColor;
+(UIColor *) navColor;
@end
@implementation UIColor (MyApp)
+(UIColor *) myColor { return [UIColor colorWithRed:0 green:0.3 blue:0.7 alpha:1.0]; }
+(UIColor *) navColor { return [UIColor colorWithRed:0.3 green:0.1 blue:0.2 alpha:1.0]; }
@end
Which I then called in other files as such:
[self.theTable setSeparatorColor:[UIColor myColor]];
But since upgrading to xCode 4.2 / iOS 5 it now causes a crash, saying "Thread 1: Program received signal: "SIGABRT". at the above line.
This happens whenever I try and reference the color regardless of which file and what context. I did not have this problem when working on iOS 4.
Is there a better was to extend a class in a way that is available to all files, or to fix the above error?
Many thanks,
Tim
Your declarations should be in a header:
and your definitions should be in your .m:
that may not necessarily be the reason for your SIGABRT, but your
@implementationblock should only ever be visible to one translation (surprised it did not give a link error, unless i misunderstood your question).Is there any more context to why the program crashed?