Preference
Preference 은 HSP 에서 기본으로 제공하는 API로 별도의 설정 없이 사용 가능하다.
Preference 는 iOS 에서 제공하는 NSUserDefaults 를 이용하여 데이터를 난독화 하여 저장하며 해당 클래스는 Optional 한 기능이므로 사용자가 별도로 개발하여 사용해도 무방하다.
get
get 은 지정된 키에 해당하는 값을 문자열 형태로 반환 한다. 이때 난독화 된 데이터는 복호화 된 후 반환 된다.
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceGetParam()
infoParam.key = key
infoParam.defaultValue = defaultValue
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
let resultData = ResultData(type: "textResultDlg", resultObject:resultDict.object(forKey: kDeviceResult) as! NSObject)
self.showSuccessDlg(resultData: resultData)
}, failure: { (resultError) in
guard let error = resultError else {
return
}
self.showErrorDlg(error: error)
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key, defaultValue]
deviceAPI.execute(withActionName: "get", params: params, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
let resultData = ResultData(type: "textResultDlg", resultObject:resultDict.object(forKey: kDeviceResult) as! NSObject)
self.showSuccessDlg(resultData: resultData)
}, failure: { (resultError) in
guard let error = resultError else {
return
}
self.showErrorDlg(error: error)
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceGetParam()
infoParam.key = key
infoParam.defaultValue = defaultValue
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
let resultData = ResultData(type: "textResultDlg", resultObject:resultDict.object(forKey: kDeviceResult) as! NSObject)
self.showSuccessDlg(resultData: resultData)
}, failure: { (resultError) in
guard let error = resultError else {
return
}
self.showErrorDlg(error: error)
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key, defaultValue]
deviceAPI.execute(withActionName: "get", params: params, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
let resultData = ResultData(type: "textResultDlg", resultObject:resultDict.object(forKey: kDeviceResult) as! NSObject)
self.showSuccessDlg(resultData: resultData)
}, failure: { (resultError) in
guard let error = resultError else {
return
}
self.showErrorDlg(error: error)
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceGetParam *infoParam = [DAPPreferenceGetParam new];
infoParam.key = key;
infoParam.defaultValue = defaultValue;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", @"defaultValue", nil];
[deviceAPI executeWithActionName:@"get" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceGetParam *infoParam = [DAPPreferenceGetParam new];
infoParam.key = key;
infoParam.defaultValue = defaultValue;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", @"defaultValue", nil];
[deviceAPI executeWithActionName:@"get" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
set
set 은 지정된 키에 원하는 데이터를 난독화 하여 저장 한다.
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceSetParam()
infoParam.key = key
infoParam.value = value
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard (dict as NSDictionary?) != nil else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key, value]
deviceAPI.execute(withActionName: "set", params: params, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceSetParam()
infoParam.key = key
infoParam.value = value
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard (dict as NSDictionary?) != nil else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key, value]
deviceAPI.execute(withActionName: "set", params: params, completion: { (dict) in
guard let resultDict = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceSetParam *infoParam = [DAPPreferenceSetParam new];
infoParam.key = key;
infoParam.value = value;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_saved", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", @"defaultValue", nil];
[deviceAPI executeWithActionName:@"set" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceSetParam *infoParam = [DAPPreferenceSetParam new];
infoParam.key = key;
infoParam.value = value;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_saved", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", @"defaultValue", nil];
[deviceAPI executeWithActionName:@"set" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
remove
remove 는 set 으로 등록된 데이터를 삭제 한다.
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceRemoveParam()
infoParam.key = key
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let _ = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key]
deviceAPI.execute(withActionName: "remove", params: params, completion: { (dict) in
guard let _ = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPPreference()
let infoParam = DAPPreferenceRemoveParam()
infoParam.key = key
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let _ = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPPreference()
let params = [key]
deviceAPI.execute(withActionName: "remove", params: params, completion: { (dict) in
guard let _ = dict as NSDictionary? else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceRemoveParam *infoParam = [DAPPreferenceRemoveParam new];
infoParam.key = key;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_removed", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", nil];
[deviceAPI executeWithActionName:@"remove" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
DAPPreferenceRemoveParam *infoParam = [DAPPreferenceRemoveParam new];
infoParam.key = key;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_removed", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPPreference new];
NSArray *params = [NSArray arrayWithObjects:@"key", nil];
[deviceAPI executeWithActionName:@"remove" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];