当你得到第一个和第二个值时,(正如你展示的tableView
那样,我假设它们不止一个),准备一个这样的数组:
- (NSArray *) getArrayToLoadDataInTableView : (NSArray *) valueFromWebService {
//load value from web service in `valueFromWebService` array in form of dictionary like MENTIONED BELOW or however convinient to you
/*NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"2", @"firstOprand",
@"2", @"secondOprand", nil];*/
NSMutableArray *array = [NSMutableArray array];
for (NSDictionary *dictionary in valueFromWebService) {
NSMutableDictionary *finalDict = [dictionary mutableCopy];
int result = [[finalDict valueForKey:@"firstOprand"] intValue] * [[finalDict valueForKey:@"secondOprand"] intValue];
[finalDict setObject:[[NSNumber numberWithInt:result] stringValue] forKey:@"result"];
[array addObject:finalDict];
}
return [NSArray arrayWithArray:array];
}
现在您可以tableView
从此方法返回的数组中加载数据。