我有以下代码调用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