以编程方式设置iphone模拟器位置 [英] Programmatically setting iphone simulator location

查看:140
本文介绍了以编程方式设置iphone模拟器位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新到XCode 4.2,我看到一个很酷的功能,允许我手动设置设备位置。有没有人知道以编程方式完成同样的事情的方法?我想在一些单元测试中设置位置。

I've just updated to XCode 4.2 and I see a cool feature that allows me to manually set the device location. Does anyone know of a way to accomplish the same thing programmatically? I'd like to set the location in some unit tests.

推荐答案

以下AppleScript将允许您设置iOS的位置模拟器。应该可以将这种脚本集成到单元测试脚本中,或让脚本生成等效的AppleEvents。

The following AppleScript will let you set the location of the iOS Simulator. It should be possible to integrate this kind of script into a unit test script, or have your script generate the equivalent AppleEvents.

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

这篇关于以编程方式设置iphone模拟器位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆