简体   繁体   中英

Objective-c : UIColor * exception 'NSInvalidArgumentException?

I am trying to store UIColor value in its object where UIColor is member of class.

When I try retrieve the value it throws error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray set]: unrecognized selector sent to instance 0x5394860'

.... Call stack at first throw:

_product.ProductTextColor = [self selectColor];

- (UIColor *)selectColor
{
    return [UIColor colorWithRed:(0.0/255) green:(204.0/255) blue:(51.0/255) alpha:1.0f];
}

ProductDetails *prod = [productList objectAtIndex:indexPath.row];
lblProductname.textColor = prod.ProductTextColor;

At last line I am trying to get value but its throwing the error. where

@property (nonatomic, assign) UIColor *ProductTextColor;

is member of Product class.

Replace declaration

@property (nonatomic, assign) UIColor *ProductTextColor;

with

@property (nonatomic, retain) UIColor *ProductTextColor;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM