1.判断字典中是否含有某个key值
import UIKit
let dict: NSDictionary = ["key1":"zhang","key2":"zhong"]
//第一种方法:swift3.0的方法
let X: Bool = dict.allKeys.contains { (key) -> Bool in
print(key)
if key as! String == "key1" {
print(1233333)
return true
}
return false
}
print(X) //输出为true
//第二种方法:遍历所有的key
for key in dict.allKeys {
print(key)
}
2.swift的debug和release
target—— Build Settings —— Other Swift Flags
设置Debug 添加 -D DEBUG(注意只设置debug)
#if DEBUG
//debug环境
#else
//正式环境
#endif