Reputation: 1087
I've create a sqlite
CoreData Application with multiple records inside:
myFile.h
@property (nonatomic, retain) NSNumber * game;
@property (nonatomic, retain) NSString * image;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * result;
@property (nonatomic, retain) NSNumber * totalWin;
myFile.m
@dynamic game;
@dynamic image;
@dynamic name;
@dynamic resul;
@dynamic totalWin;
And i read all in UITableView
custom, but i will in the first page get a general report for all game, for example:
If i played 5 games i have 5 cells in my UITableView
how can get the total amount in a unique NSNumber
like a:
UILabel *myTotal;
myTotal = //here i want to get total game from all my cells
And in the 5 cells have a NSNumber game:
1St game = 5 2St game = 3 3St game = 4 4St game = 6 5St game = 1
How show in the firsrt page one label with this amount 19
This is what i load in to a TableView:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [archive count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
UILabel *gameName = (UILabel *)[cell viewWithTag:2];
gameName.text = [archive[indexPath.row]name];
int gameInt = [[archive [indexPath.row] game]intValue];
UILabel *gameValue = (UILabel *)[cell viewWithTag:3];
gameValue.text = [NSString stringWithFormat:@"%d",gameInt];
return cell;
}
Upvotes: 0
Views: 221
Reputation: 1087
solved with Larme code thanks
Try
[archive valueForKeyPath:@"@sum.game"];
(or replace game, by resul, totalWin or whatever you want).
Upvotes: 1