Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect iOS Simulator vs. iOS Device

I am working on a project using Xamarin.iOS and I have a situation where a behavior in the simulator inexplicably is not the same on an actual device (setting the region of a mapview centers differently).

I want to be able to set a value for a variable at runtime based on whether the app is running on the simulator or a real device. How can I detect this?

like image 874
Jason Hartley Avatar asked May 29 '13 02:05

Jason Hartley


1 Answers

You can execute different code at runtime like this:

if (ObjCRuntime.Runtime.Arch == Arch.DEVICE) {
} else {
}

But it's always good to investigate (ask around here, forums, bug reports) why the behaviour differs between the two (just to make sure it does not hide a bug that could bite you later).

like image 82
poupou Avatar answered Sep 21 '22 21:09

poupou