我对Swift 4字符串操作的最佳实践感到有点困惑。
如何处理以下问题:
let str = "test"
let start = str.index(str.startIndex, offsetBy: 7)
Thread 1: Fatal error: cannot increment beyond endIndex假设您不知道上面变量'str‘的长度。既然'start‘不是可选值,那么防止这种崩溃的最佳实践是什么呢?
https://stackoverflow.com/questions/47740981
复制相似问题