我刚刚更新到XCode 4.2,发现有一个很酷的功能可以手动设置设备位置。请问有没有办法以编程方式实现相同的功能?我想在一些单元测试中设置位置。
我刚刚更新到XCode 4.2,发现有一个很酷的功能可以手动设置设备位置。请问有没有办法以编程方式实现相同的功能?我想在一些单元测试中设置位置。
tell application "iOS Simulator"
activate
end tell
tell application "System Events"
tell process "iOS Simulator"
tell menu bar 1
tell menu bar item "Debug"
tell menu "Debug"
tell menu item "Location"
click
tell menu "Location"
click menu item "Custom Location…"
end tell
end tell
end tell
end tell
end tell
tell window 1
set value of text field 1 to "40.69"
set value of text field 2 to "-74.045"
click button "OK"
end tell
end tell
end tell
iOS Simulator
应该改为 Simulator
,Debug
改为 Features
。激活模拟器需要2分钟,但我不知道原因。 - matebende您可以使用预处理条件包含;像这样检查TARGET_IPHONE_SIMULATOR
宏:
#if TARGET_IPHONE_SIMULATOR
float longitude = 39.1234;
// etc
#else
float longitude = myLocationManager.longitude
#endif