How to convert NSNumber objects for computational purposes?

允我心安 提交于 2019-12-01 02:50:54

Use the "value" methods of the NSNumber class such as doubleValue.

// Initialized to something earlier
NSNumber * x, y;

//Convert NSNumbers to double
double xD = [x doubleValue]; 
double yD = [y doubleValue];

// You can now use regular arithmetic operators
double zD = 10.0 / ((x + y / 60.0) / 60.0);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!