IASKSettingsStoreFile.m 파일 을 딕셔너리에저장
IASKSettingsStore.m 셋팅값을 저장동작
IASKSettingsStoreUserDefaults ///NSUserDefaults standardUserDefaults 에 키 밸류 값을 저장
- (void)setBool:(BOOL)value forKey:(NSString*)key {
[[NSUserDefaults standardUserDefaults] setBool:value forKey:key];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
settingsBundle 파일을 읽어온다음 밸류 어레이와 키 어레이에 저장
locateSettingsFile .plist 섹션과 파일을 읽어온다
IASKSettingsReader.m
linphone-iphone/Classes/Utils/InAppSettingsKit/Models/IASKSettingsReader.m
#import "IASKSettingsReader.h"
#import "IASKSpecifier.h"
@interface IASKSettingsReader (private)
- (void)_reinterpretBundle:(NSDictionary*)settingsBundle; //
- (BOOL)_sectionHasHeading:(NSInteger)section;//
- (NSString *)platformSuffix;
- (NSString *)locateSettingsFile:(NSString *)file;//
@end
@implementation IASKSettingsReader
@synthesize path=_path,
localizationTable=_localizationTable,
bundlePath=_bundlePath,
settingsBundle=_settingsBundle,
dataSource=_dataSource,
hiddenKeys = _hiddenKeys;
- (id)init {
return [self initWithFile:@"Root"];// 함수호출 initWithFile Root.plist 불러들임
}
- (id)initWithFile:(NSString*)file {
if ((self=[super init])) {
self.path = [self locateSettingsFile: file];//파일위치
[self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:self.path]];// 셀프의 셋팅번들파일을지정 setSettingsBundle
self.bundlePath = [self.path stringByDeletingLastPathComponent];//패스컴포넌트를 삭제 stringByDeletingLastPathComponent = 경로명임 라스트컴포넌트 즉파일명을 제외하고의미
_bundle = [NSBundle bundleWithPath:[self bundlePath]];//번들과 패스
// Look for localization file. //현지화언어 존재확인
self.localizationTable = [self.settingsBundle objectForKey:@"StringsTable"];//self.settingsBundle 에서 StringsTable 가져오기
if (!self.localizationTable)
{
// Look for localization file using filename
self.localizationTable = [[[[self.path stringByDeletingPathExtension] // removes '.plist'결국 . plist 삭제
stringByDeletingPathExtension] // removes potential '.inApp'
lastPathComponent] // strip absolute path
stringByReplacingOccurrencesOfString:[self platformSuffix] withString:@""]; // removes potential '~device' (~ipad, ~iphone)
if([_bundle pathForResource:self.localizationTable ofType:@"strings"] == nil){
// Could not find the specified localization: use default
self.localizationTable = @"Root";
}
}
if (_settingsBundle) {
[self _reinterpretBundle:_settingsBundle];
}
}
return self;
}
- (void)dealloc {
_path = nil;
_localizationTable = nil;
_bundlePath = nil;
_settingsBundle = nil;
_dataSource = nil;
_bundle = nil;
_hiddenKeys = nil;
}
///////////////////////////////////////////
읽어들인 딕셔너리의 요소를 분류 리턴
IASKSpecifier.m
// setSpecifierDict xxxx,plist
#import "IASKSpecifier.h"
#import "IASKSettingsReader.h"
@interface IASKSpecifier ()
@property(nonatomic, strong) NSDictionary *multipleValuesDict;
- (void)_reinterpretValues:(NSDictionary*)specifierDict;
@end
@implementation IASKSpecifier
@synthesize specifierDict=_specifierDict;
@synthesize multipleValuesDict=_multipleValuesDict;
@synthesize settingsReader = _settingsReader;
- (id)initWithSpecifier:(NSDictionary*)specifier {
if ((self = [super init])) {
[self setSpecifierDict:specifier];///setSpecifierDict 에 specifier 저장
if ([[self type] isEqualToString:kIASKPSMultiValueSpecifier] || [[self type] isEqualToString:kIASKPSTitleValueSpecifier]) {//멀티밸류 타잍틀밸류
[self _reinterpretValues:[self specifierDict]]; //_reinterpretValues 함수를이용 밸류 어래이 와 타이틀 어래이에 저장
}
}
return self;
}
- (void)_reinterpretValues:(NSDictionary*)specifierDict {
NSArray *values = [_specifierDict objectForKey:kIASKValues];
NSArray *titles = [_specifierDict objectForKey:kIASKTitles];
- (NSInteger)multipleValuesCount {
return [[_multipleValuesDict objectForKey:kIASKValues] count];
}
- (NSArray*)multipleValues {
return [_multipleValuesDict objectForKey:kIASKValues];
}
- (NSArray*)multipleTitles {
return [_multipleValuesDict objectForKey:kIASKTitles];
}
- (NSString*)file {
return [_specifierDict objectForKey:kIASKFile];
}
- (id)defaultValue {
return [_specifierDict objectForKey:kIASKDefaultValue];
}
- (id)defaultStringValue {
return [[_specifierDict objectForKey:kIASKDefaultValue] description];
}