i am storing my “custom button” in NSUserdefaults using the following code.But i am getting an error “[UIImage encodeWithCoder:]: unrecognized selector sent to instance” while converting the object to NSdata..here “custom button” is UIButton class. Anyone know why…? please help me.
Custom_button *lock11 = (Custom_button*)[menu1 viewWithTag:100];
NSLog(@"opened lock1 ========= %@",lock11);
lock11.is_menu_lock_opened = YES;
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:lock11]; //[NSKeyedArchiver archivedDataWithRootObject:lock11];
[prefs setObject:myEncodedObject forKey:@"set1lock"];
Implement this method into your Custom_button Class
initWithCoder and encodeWithCoder for all object
For more detail click here