guard characters.count > index in yep_mentionWordInIndex

This commit is contained in:
nixzhu
2016-01-20 13:36:56 +08:00
parent 3d9e7b18f4
commit 5fe8a419d2
+3 -1
View File
@@ -47,11 +47,13 @@ extension String {
func yep_mentionWordInIndex(index: Int) -> (wordString: String, mentionWordRange: Range<Index>)? {
println("startIndex: \(startIndex), endIndex: \(endIndex), index: \(index), length: \((self as NSString).length), count: \(self.characters.count)")
guard index > 0 else {
return nil
}
guard (self as NSString).length > index else {
guard self.characters.count > index else {
return nil
}