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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With