我遇到一个问题,我的Monotouch应用程序有时会在收到内存警告后崩溃.请看下面的堆栈跟踪.
Received memory warning. Level=2
DTMobileIS[2299] : _memoryNotification : {
OSMemoryNotificationLevel = 2;
timestamp = "2011-04-11 14:29:09 +0000";
}
Toplevel exception: System.MissingMethodException: No constructor found for Myapp.UI.BoardController::.ctor(System.IntPtr)
at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in :0
at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x00000] in :0
at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in :0 … 我需要在我的应用中测量几个地方的经过时间.因此,我正在寻找一种API,它可以让我访问一个单调增加的时钟,该时钟不受系统时钟变化或夏令时的影响(类似于启动后的毫秒数).
一些示例代码来说明我的问题:
var t1 = SomeClockFunction();
// bunch of code
// ...
var t2 = SomeClockFunction();
var elapsedTime = t2 - t1;
Run Code Online (Sandbox Code Playgroud)
我不能只使用系统时钟,因为如果在t1和t2之间,时钟被用户更改或手机进入/退出夏令时,则可能导致错误的测量.
Objective-C用户可以访问CACurrentMediaTime()或mach_absolute_time().MonoTouch中的等价物是什么?