xcode 中是否有一个函数可以为您提供该应用程序运行了多长时间?
Is there a function in xcode that provides you with how long the app has been working?
xcode 中是否有函数或 class 参考可以为您提供该应用程序运行了多长时间??而不是通过在应用程序启动后存储 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 *current;加倍但仍然是同样的问题
你的问题是指针星号。它试图告诉你。 (又名 'double *')与(又名 'double')。声明变量时删除星号。 NSTimeInterval *当前;应该是 NSTimeInterval 当前;基元不像对象那样使用指针。
xcode 中是否有函数或 class 参考可以为您提供该应用程序运行了多长时间??而不是通过在应用程序启动后存储 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 *current;加倍但仍然是同样的问题
你的问题是指针星号。它试图告诉你。 (又名 'double *')与(又名 'double')。声明变量时删除星号。 NSTimeInterval *当前;应该是 NSTimeInterval 当前;基元不像对象那样使用指针。