1
2
3
4
| CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = @[ [colorOne CGColor], [colorTwo CGColor] ];
return gradient;
|
The above code will cause this compiler error:
/path/to/MyViewController.m:31:26: Collection element of type 'CGColorRef' (aka 'struct CGColor *') is not an Objective-C object
It can be fixed by casting to id
1
2
3
4
| CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = @[ (id)[colorOne CGColor], (id) [colorTwo CGColor] ];
return gradient;
|
It is a new behavior due to the use of ARC