Reputation: 2206
I have the following code called with NSNotification
center, i know its being called because the array is appearing in the NSLog
, but my label chipCount
is not updating with the new value. Is there perhaps a method I applied wrong when extracting the string from the array?
-(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];
}
}
Upvotes: 1
Views: 325
Reputation: 26
I think this is a multithread problem. Update UI must in the main thread. Maybe readPlist
is
executed in another thread.
Try this code below, maybe it can help you:
[self performSelectorOnMainThread:@selector(theProcess:) withObject:nil waitUntilDone:YES];
- (void) theProcess:(id)sender
{
....
chipCount.text = [NSString stringWithFormat:@"%i", chipsFloat];
}
Upvotes: 1
Reputation: 2399
Assusming that chipcount is a UILabel.. is it possible that you need to tell it to refresh the label?
[chipcount setNeedsDisplay];
Just an idea.
Upvotes: 0