判断是否为空 使用的是Collection协议里isEmpty的判断. public var isEmpty: Bool { return startIndex == endIndex } startIndex 总是返回 0. public var startIndex: Int { return 0 } endIndex代码如下: @inlinable public var endIndex: Int { @inlinable get { return _getCount() } } 最终用到…
最近在回答StackOverflow的问题时,发现performSelector方法在Swift被去掉,Apple的注释是这个方法被去掉是因为不安全: NOTE The performSelector: method and related selector-invoking methods are not imported in Swift because they are inherently unsafe. 如果在Swift调用这个方法会编译出错: 'performSelector' is…
http://blog.csdn.net/woaifen3344/article/details/30244201 Swift语言使用var定义变量,但和别的语言不同,Swift里不会自动给变量赋初始值, 也就是说变量不会有默认值,所以要求使用变量之前必须要对其初始化 .如果在使用变量之前不进行初始化就会报错: var stringValue : String //error: variable 'stringValue' used before being initialized //let …