小编sam*_*n01的帖子

无法为NSNumber分配浮点数

我的根模型的m文件中有以下代码:

-(id)init {
    if(self == [super init]) {
        self.rPrices = [[NSMutableArray alloc]init];
        self.rPrices = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil];
}
    return self;
}

-(void)saveData:(NSMutableData *)data toFile:(NSString *)file {
float nR4;
nR4 = (some calculations ......)

[self.rPrices addObject:[[NSNumber alloc] numberWithFloat:nR4]];

}
Run Code Online (Sandbox Code Playgroud)

当我尝试添加对象时出现以下错误: 由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [NSPlaceholderNumber numberWithFloat:]:发送到实例的无法识别的选择器

谢谢

iphone objective-c xcode4

2
推荐指数
1
解决办法
4844
查看次数

标签 统计

iphone ×1

objective-c ×1

xcode4 ×1