如何将long long转换为NSnumber?

时间:2017-10-31 06:32:54

标签: ios objective-c nsnumber

long long mServerDurationTime = (_mExpTime.longValue) - (serverTime.longValue);
long long curTime = [[NSDate date] timeIntervalSince1970] * 1000;
NSNumber newDeviceTime  = (curTime + mServerDurationTime);

我希望将newDeviceTime保存为NSNumber。

2 个答案:

答案 0 :(得分:4)

long long mServerDurationTime = (_mExpTime.longValue) - (serverTime.longValue);
long long curTime = [[NSDate date] timeIntervalSince1970] * 1000;
NSNumber* newDeviceTime  = @(curTime + mServerDurationTime);

您可以通过以下非常简单的方式将long long,int,CGFloat,...转换为NSNumber:

NSNumber* number = @(YOUR_NUMBER);

答案 1 :(得分:0)

你可以尝试

NSNumber * numberValue = [NSNumber numberWithUnsignedLongLong:(curTime + mServerDurationTime)];