首页 > 移动平台 > 详细

iOS Swift判断代码运行在模拟器上

时间:2016-02-18 16:22:06      阅读:171      评论:0      收藏:0      [点我收藏+]

iOS模拟器有些功能没有,比如拍照,因此代码中需要加个模拟器判断,查了好多文章,终于找到了。swift代码如下:


struct Platform {
    static let isSimulator: Bool = {
        var isSim = false
        #if arch(i386) || arch(x86_64)
            isSim = true
        #endif
        return isSim
    }()
}

// Elsewhere...

if Platform.isSimulator {
    // Do one thing
}
else {
    // Do the other
}

参考 http://themainthread.com/blog/2015/06/simulator-check-in-swift.html

iOS Swift判断代码运行在模拟器上

原文:http://blog.csdn.net/offbye/article/details/50686407

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!