学习swift3.0的一些问题

来源:互联网 发布:网络转账骗局怎么处理 编辑:程序博客网 时间:2024/05/01 06:52

1.判断字典中是否含有某个key值

import UIKitlet 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//第二种方法:遍历所有的keyfor  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
0 0
原创粉丝点击