2

How to remove [[UIColor grayColor] CGColor] stupid warning?

[self setValue:
     [[UIColor grayColor] CGColor] 
          forKeyPath:[NSString stringWithFormat:@"_View_%@%d.layer.borderColor", 
              i>=10?@"":@"0", i]];

Incompatible pointer types sending 'CGColorRef' (aka 'struct CGColor *') to parameter of type 'id'

thanks.

4

2 回答 2

2

cast CGColor to id type:

[self setValue:
     (id)[[UIColor grayColor] CGColor] 
          forKeyPath:[NSString stringWithFormat:@"_View_%@%d.layer.borderColor", 
              i>=10?@"":@"0", i]];
于 2012-11-27T11:52:04.353 回答
0

This will perform same as above code.

[self setValue:
 (id)[[UIColor grayColor] CGColor] 
      forKeyPath:[NSString stringWithFormat:@"_View_%02d.layer.borderColor", i]];
于 2013-06-16T12:24:43.033 回答