第一次遇到这种判断、Mark一下
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
}
网友评论