2013-03-15 2 views
0

내 앱 설정 plist에 plist가 있습니다.plist에서 업데이트 된 데이터 얻기

나는 2 개의 전망이있다.

통화 버튼으로 첫 번째보기 - 나는 appdelegate 사전에서 전화 번호를받습니다. 두 번째보기 전화 번호를 설정했습니다. 전화 번호를 변경할 때 변경 사항이 없습니다. 변경 사항을 적용하려면 앱을 다시로드해야합니다. AppDelegate에 :

NSString *path = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]; 
self.settingsDic = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; 

firstView :

이 내 코드는

self.app=(AppDelegate*) [UIApplication sharedApplication].delegate; 
[self.app getDataFromPlist]; 
emergencyPhone=[self.app.settingsDic objectForKey:@"emergencyPhone"]; 
if (emergencyPhone.length==0) { 
[btnEmergency setEnabled:NO]; 
btnEmergency.titleLabel.numberOfLines=3; 
[btnEmergency setTitle:@" Not set " forState:UIControlStateNormal]; 
} 

settingsView :

- (IBAction)btnSaveSettings:(id)sender { 
[self.app.settingsDic setValue:[NSString stringWithFormat:@"%@",etEmergencyPhone.text] forKey:@"emergencyPhone" ]; 
etEmergencyPhone.borderStyle=UITextBorderStyleNone; 
[etEmergencyPhone setEnabled:NO]; 
NSString *path = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]; 
[self.app.settingsDic writeToFile:path atomically:YES]; 
[self.app getDataFromPlist]; 

} 
+0

내가 전화 사용자가 정의하고 전화를 걸 수있는 버튼이 있습니다. 전화가 설정되지 않으면 버튼이 작동하지 않습니다. 설정 문제 전화 번호를 삭제하면 버튼이 작동을 멈 춥니 다. 하지만 전화 번호를 만든 후에는 버튼이 작동하지 않습니다. 소프트웨어를 종료하고 다시 시작해야합니다. 독립 변경 – allpnay

+0

데이터를 사용해야합니다. – allpnay

답변

0
self.app=(AppDelegate*) [UIApplication sharedApplication].delegate; 
[self.app getDataFromPlist]; 
emergencyPhone=[self.app.settingsDic objectForKey:@"emergencyPhone"]; 
if (emergencyPhone.length==0) { 
[btnEmergency setEnabled:NO]; 
} 
else{ 
[btnEmergency setEnabled:YES]; 
}