2014-12-15 2 views
-4

NSUserDefaults를 사용하여 내 앱에 저장된 일부 데이터를 저장합니다 (예 : NSNumber 속성이있는 일부 개체). 앱 업데이트로 NSUserDefault에 저장된 데이터 유형을 변경하십시오.

self.is_new_device_verification_enabled = [decoder decodeNumberForKey:@"is_new_device_verification_enabled"];;

@interface STAccountInfo : NSObject 
 

 
@property(nonatomic,strong)NSNumber* is_new_device_verification_enabled; 
 
@property(nonatomic,strong)NSNumber* is_new_device_verification_enabled_by_enterprise; 
 
@property(nonatomic,strong)NSNumber* is_collab_related_function_restricted;

하지만 내 새로운 버전의 유형을 bool에 몇 가지의 NSNumber 속성을 업데이트 할 필요가있다.
@interface STAccountInfo : NSObject 
 

 
@property(nonatomic,assign)BOOL is_new_device_verification_enabled; 
 
@property(nonatomic,assign)BOOL is_new_device_verification_enabled_by_enterprise; 
 
@property(nonatomic,assign)BOOL is_collab_related_function_restricted;
저장된 개체를 디코딩하면 잘못된 데이터 형식으로 인해 예외가 발생합니다. 디코더 부분에서 무엇을해야합니까? 여기

는 현재 디코딩 코드 :

self.is_new_device_verification_enabled = [decoder decodeBoolForKey:@"is_new_device_verification_enabled"]; 
+0

당신이 여기에 코드를 게시 할 수있는 이전 키에 대한 값을 제거 – Sam

답변

1

난 당신이 실행 한 후 때 새 사용자 기본 설정에 대한 새 키 이름을 사용하는 것이 좋습니다 것입니다 :

  1. 확인의 존재를 이전 키 - 존재하지 않으면 평소와 같이 진행합니다.
  2. 가 존재하는 경우, 새로운 키에 이전 키 값 마이그레이션 (예를 들어, 변화 '1' 'YES'로)
관련 문제