不会让我添加Float到NSMutableArray

Top*_*hef 0 iphone cocoa-touch objective-c

目前,我正在尝试实现一个方法,该方法在两个单独的数组中存储两个UITextField值(在用户键入之后).但是,当我使用控制台运行程序时,每个数组的NSLog都返回空值(没有插入浮点数).

我尝试切换到int,但它说存在不兼容问题.谁知道我哪里出错了?

-(IBAction)logSet:(id)sender {
    [repsUsed insertObject:[reps.text floatValue] atIndex:0];
    [weightUsed insertObject:[weight.text floatValue] atIndex:0];

    NSLog(@"%@", repsUsed);
    NSLog(@"%@", weightUsed); 
}
Run Code Online (Sandbox Code Playgroud)

Man*_*wal 9

NSMutable只能添加对象和float,int不是用于插入float值的对象类型,使其成为一个对象

[repsUsed insertObject:[NSNumber numberWithFloat:[reps.text floatValue]] atIndex:0];