Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in the "Objective-C Generated Interface Header Name"

Tags:

ios

swift

swift2

I've been upgrading my project to Swift2. After resolving many errors, i got an error when i build the project.

The error is located in the Objective-V Generated Interface Header,

Xcode is printing this error Type argument 'CGColorRef' (aka 'struct CGColor *') is neither an Objective-C object nor a block type

Here is the code, the error is printed on the line between the **:

SWIFT_CLASS("_TtC519RadialGradientLayer")
@interface RadialGradientLayer : CALayer
**@property (nonatomic, copy) NSArray<CGColorRef> * __nullable colors;**
@property (nonatomic, copy) NSArray<NSNumber *> * __nullable locations;
@property (nonatomic) CGPoint center;
@property (nonatomic) CGFloat startRadius;
@property (nonatomic) CGFloat endRadius;
- (nullable instancetype)initWithCoder:(NSCoder * __nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithLayer:(id __nonnull)layer OBJC_DESIGNATED_INITIALIZER;
- (void)drawInContext:(CGContextRef __nonnull)ctx;
+ (BOOL)needsDisplayForKey:(NSString * __nonnull)key;
@end

I guess that is link to this class

class RadialGradientLayer: CALayer {

    var colors: [CGColor]? {
        didSet {
            self.setNeedsDisplay()
        }
    }

    var locations: [CGFloat]? {
        didSet {
            self.setNeedsDisplay()
        }
    }
    ...
}

I didn't found any answer anywhere or even a clue so here i'm.

like image 803
Luis Avatar asked Dec 01 '15 13:12

Luis


1 Answers

the error is trying to tell you that you can't have an NSArray contain primitive types.

you would get a similar error if you attempted to do something like this:

@property (nonatomic, strong) NSArray <Int>* intArray;

one way to fix this would be to make your swift class hold an array of UIColor instead of CGColor.

like image 135
Casey Avatar answered Oct 26 '22 19:10

Casey