1

I used to use this code to retrieve the iOS uptime using Xamarin's classic API:

var uptime = ObjCRuntime.Messaging.Double_objc_msgSend(NSProcessInfo.ProcessInfo.Handle, 
                                                                  new ObjCRuntime.Selector ("systemUptime").Handle);
var ts = TimeSpan.FromSeconds(uptime);
return ts;

I am trying to convert to the Unified API and now I am getting this build error for the above:-

Error CS0122: `ObjCRuntime.Messaging' is inaccessible due to its protection level (CS0122)

I am not sure how to convert this. Can anyone help?

Thanks in advance

joehanna
  • 1,471
  • 1
  • 11
  • 22

1 Answers1

2

The unified api has a ProcessInfo that is shared between iOS and OS-X

So using that with your code/variable names:

var uptime = Foundation.NSProcessInfo.ProcessInfo.SystemUptime;
var ts = TimeSpan.FromSeconds(uptime);
return ts;
SushiHangover
  • 73,120
  • 10
  • 106
  • 165