我有以下代碼調用NSNotification
中心,我知道它被調用,因爲該數組出現在NSLog
,但我的標籤chipCount
未更新與新值。從數組中提取字符串時,是否可能有錯誤?NSNotification調用,但標籤不會更新
-(NSString *) dataFilePath {
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
return [documentDirectory stringByAppendingPathComponent:@"Chips.plist"];
}
-(void)readPlist {
[self dataFilePath];
NSString *filePath = [self dataFilePath];
if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
chipArray = [[NSArray alloc] initWithContentsOfFile:filePath];
NSLog(@"%@\n", chipArray);
NSLog(@"%@\n", filePath);
NSString *chipcountString = [chipArray objectAtIndex:0];
chipsFloat = [chipcountString intValue];
chipCount.text = [NSString stringWithFormat:@"%i", chipsFloat];
//[arrayForPlist release];
}
}
是chipCount一個IBOutlet? – rooster117
是的,它在我的頭像IBOutlet UILabel * chipCount; – inVINCEable
如果你沒有看到標籤中的任何內容,我建議只是嘗試將它設置爲一個不變的字符串值,如果你還沒有。這至少會排除你的標籤沒有正確連接。 – rooster117