Initialize NSArray with floats?

后端 未结 7 2105
你的背包
你的背包 2021-02-12 19:54

Is this a valid way to initalize an NSArray with float objects?

NSArray *fatArray = [NSArray arrayWithObjects:
                    [NSNumber numberWithFloat:6.9]         


        
7条回答
  •  误落风尘
    2021-02-12 20:30

    going off on a slight tangent, if all you want to do is store an array of floats and don't really need the added functionality of an NSArray or NSNumber, then you should also consider just a standard C array:

    float fatArray[] = {6.6, 6.9, 4.7, 6.9};
    

提交回复
热议问题