- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个包含多条记录的 sqlite
CoreData 应用程序:
我的文件.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;
我的文件.m
@dynamic game;
@dynamic image;
@dynamic name;
@dynamic resul;
@dynamic totalWin;
我在 UITableView
自定义中阅读了所有内容,但我会在第一页获得所有游戏的一般报告,例如:
如果我玩了 5 场比赛,我的 UITableView
中有 5 个单元格,如何才能在唯一的 NSNumber
中获得总金额,例如:
UILabel *myTotal;
myTotal = //here i want to get total game from all my cells
并且在 5 个单元格中有一个 NSNumber 游戏:
1St game = 5
2St game = 3
3St game = 4
4St game = 6
5St game = 1
如何在第一页显示这个数量的标签19
这是我加载到 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;
}
最佳答案
用 Larme 代码解决了,谢谢
Try
[archive valueForKeyPath:@"@sum.game"];
(or replace game, by resul, totalWin or whatever you want).
关于ios - 带有 NSNumber 的 CoreData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25014577/
我正在开发一些代码,其中我使用扫描仪从字符串中获取 NSNumbers,例如 x 和 y。 现在我想从 x 和 y 计算一些简单的东西,比如 z = 10.0/(x + y/60.0)/60.0)。我
第一次发帖。 NSNumber 的 floatValue 方法有问题——不知何故,它返回一个不精确的数字。问题在于:我将一堆 NSNumbers 存储在一个数组中,如下所示: NSArray *a =
我在尝试使用从基类继承的泛型函数的参数时遇到标题错误 基类: BaseBottomBar: UIView { ... func formatDetailText(value: T...
我有下面这行代码 NSNumber *myValue = loadTempValue*0.420; 我试图将 *myValue 的值设置为 loadTempValue*0.420 的值, 但是,我得到
我在将 NSNumber 转换为字符串以及将字符串转换为 NSNumber 时遇到问题。 这是一个示例问题: NSString *stringValue = @"9.2"; NSNumberForma
有一个坐标对象,具有三个变量纬度(NSNumber),经度(NSNumber)和时间(NSDate),为了在我的模拟器上检查程序,我给出了以下代码 [coordinate setLatitude:[N
简单方法:我有一个 SearchView,用户可以在其中选择一些 CoreDate,然后他可以搜索 Name、City( >NSString) 和Clientnumber (NSNumber) NSP
我转换这个 Objective-C 函数: - (NSArray *)grt_map:(id (^)(id))block { NSMutableArray *newArray = [NSMut
示例:我有一个 NSInteger,我将其包装到一个 NSNumber 对象中。现在我想要一个具有该 NSInteger 值的 NSDecimal。 那么我可以问: NSDecimal myDecim
我有这个自定义类: @interface MyModel : NSObject @property (nonatomic,strong) NSString *id_name; @property (n
在我的应用程序中,我进入 CoreData 并获取一个类型为 Double 的条目,然后我试图将该值放入我的应用程序的文本字段中。 这看起来像 lengthTextField.text = lastS
用户输入一个数字( float 或整数),并且它必须大于下限。 这是从 UITextField 获取数字的代码: NSNumberFormatter * f = [[NSNumberFormatter
我正在为 iPhone 应用程序使用 NSNumber,并看看我能用它做什么。对于我的大多数变量,我简单地将它们存储为“int”或“float”或其他类型。但是,当我必须传递一个对象(例如在字典中)时
我使用 [NSNumber numberWithDouble:] 方法来形成我的 NSNumber。但是,由于某些值可能很大,我想知道是否有办法告诉 NSNumber 用科学记数法表示自己。提前致谢!
一个 NSNumber 可以存储不同的基本类型,如short、int、long、long long、float、double 但是当我这样做时,尺寸会改变 @(long long) 相比 @(int)
我编写了一个 Objective-C 类,并且在我的 iPhone 项目中的多个 View 中使用它的共享实例。它的成员变量包括 bools、ints、NSStrings 和一个 NSNumber。共
创建一个 ARC 新项目并将此代码注入(inject)到 didFinishLaunchingWithOptions 中。 for (int i=0; i < 1000000; i++) {
我对 Objective C 比较陌生,需要一些数组帮助。 我有一个 plist,其中包含一个字典和一个 NSNumber 数组,还有更多数组可供使用稍后添加。 NSMutableDictionary
我正在尝试将 NSNumber 放入数组中: NSNumber *n = [NSNumber numberWithInt:1]; [[array objectAtIndex:0] setValue:n
我正在开发一个简单的计算器 iPhone 应用程序。只是为了练习的目的。我有一个 IBAction 方法来存储用户输入的数字。整个概念是计算器应用程序堆积待处理的操作,以便用户可以执行多个操作,并且屏
我是一名优秀的程序员,十分优秀!