Initialize NSArray with floats?

后端 未结 7 1802
情歌与酒
情歌与酒 2021-02-12 20:05

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:38

    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};
    

提交回复
热议问题