Ios xcode中是否有一个函数可以向您提供应用程序运行的时间?

Ios xcode中是否有一个函数可以向您提供应用程序运行的时间?,ios,xcode,time,Ios,Xcode,Time,xcode中是否有函数或类引用可以向您提供应用程序工作的时间??而不是通过在应用程序启动后存储NSDate的值,然后从当前时间中减去它来手动执行 更新:我发现了以下方法 in viewdidload initial= [NSDate date];// stores the initial time Once a button is pressed NSLog(@"%f", [next timeIntervalSinceDate:initial]);// this displays the

xcode中是否有函数或类引用可以向您提供应用程序工作的时间??而不是通过在应用程序启动后存储NSDate的值,然后从当前时间中减去它来手动执行

更新:我发现了以下方法

in viewdidload
initial= [NSDate date];// stores the initial time

Once a button is pressed 
 NSLog(@"%f", [next timeIntervalSinceDate:initial]);// this displays the time since the start of the app
我现在的问题是如何将打印在名为current的变量中的值还原

current =[next timeIntervalSinceDate:initial];
我收到以下错误:从不兼容的类型“NSTimeInterval”(又名“double”)分配给“NSTimeInterval*”(又名“double*”)

其中所有变量定义如下:

NSDate *initial;
NSDate *next;
NSTimeInterval *current;

我试图更改NSTimeInterval*当前值;要加倍但仍然是相同的问题

您的问题是指针星号。它正试图告诉你这一点。(又名“double*)vs(又名“double”)。声明变量时删除星号。NSTimeInterval*电流;应为NSTimeInterval电流;基本体不像对象那样使用指针