See this code:
int i = years;
NSLog(@"Years i: %i",i);
NSString *syears= [NSString stringWithFormat:@"%d",i];
menuList = [[NSMutableArray alloc] init];
[menuList addObject:[NSMutableDictionary
dictionaryWithObjectsAndKeys:
@"years", kLeftKey,
syears, kRightKey, nil, kControllerKey, nil]];
The above is an extract from ViewWillAppear
. When I switch between tabs ViewWillAppear
is doing it's job and the data is updating down as far as NSString *syears= [NSString stringWithFormat:@"%d",i];
but after that my array doesn't get updated with the latest value of syears. I tried using setObject
and setValue
but these don't work with NSMutableArray
. Any ideas?
Keys and values in NSDictionary
need to be non- nil
NSObject
s. So you've definitely got an issue with a nil
in there, and there may be a question about kLeftKey
et al, for which you haven't shown the definitions.
More generally, it would help to know what you are doing with menuList
and what you mean by "my array doesn't get updated". Are you trying to display it? Using it as a data source somewhere? You are creating the array anew here -- could a previous reference be being left around and displayed?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.