我包括在我prefix.pch文件头像这样:类不再和Xcode 4.2工作
#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
在包含的头是一个类扩展:
@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
然后我在其他文件中被称为例如:
[self.theTable setSeparatorColor:[UIColor myColor]];
但自从升级到4.2的Xcode /的iOS 5,现在导致信用评级机构h,在上面的行说"Thread 1: Program received signal: "SIGABRT".
。
每当我尝试引用颜色而不管哪个文件和什么上下文时,都会发生这种情况。在iOS 4上工作时,我没有这个问题。
有没有更好的方法是以对所有文件都可用的方式扩展类,或修复上述错误?
非常感谢,
添
'[UIColor plColor]'的实现在哪里? – Lukman
对不起卢克曼,修改了代码以使其通用,但忘记重命名最后一个!现在编辑了这篇文章。如果只有修复是这么简单:)(或者它可能仍然是,谁知道) – Tim