我使用下面的代碼將我的「自定義按鈕」存儲在NSUserdefaults中。但是,在將對象轉換爲NSdata時,出現「[UIImage encodeWithCoder:]:無法識別的選擇器發送到實例」的錯誤。此處的「自定義按鈕」爲UIButton類。有人知道爲什麼...?請幫幫我。在NSUserdefaults問題中存儲custom_button?
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"];
的UIImage不符合NSCoding iOS 5中 – jackslash 2012-04-19 12:01:28
而且你確定他的目標是iOS 5的只要? – Lefteris 2012-04-19 12:02:48
但它不是UIImage class.its UIbutton類only .. – Madhumitha 2012-04-19 12:13:28