Created
January 26, 2018 09:17
-
-
Save acalism/aa7f6dba4254f2d46ae1225b0dc70a51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 这两个方法有冲突(调用时无法区分),除非其中一个去掉IndexPath后的问号 | |
/// 不能有默认参数 nil,因为inout不能操作常量 | |
func shouldChange(indexPath: inout IndexPath?) -> Bool { | |
indexPath = IndexPath(item: 0, section: 1) | |
return true | |
} | |
/// 可以有默认参数 nil, | |
func shouldChange(indexPath: UnsafeMutablePointer<IndexPath?>? = nil) -> Bool { | |
indexPath?.pointee = IndexPath(item: 0, section: 0) | |
return false | |
} | |
var ip: IndexPath? | |
let should = shouldChange(indexPath: &ip) | |
if let i = ip { | |
print(i, should) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment