Reputation: 45
I am building an application which incorporates the use of both firebase and parse,and for some reason i keep getting the fatal error: fatal error: subscript: subRange extends past String end
Not sure why i keep getting this ;/
I tried doing a search and found nothing. Thanks.
Upvotes: 3
Views: 3505
Reputation: 79
Asynchronous thread causes this problem may occur.
Instead of using DespatchQueue.main.async{}
, use DespatchQueue.main.sync{}
.
Upvotes: 1
Reputation: 47
It's kinda similar to "Array index out of range", but for Strings.
let str = "qwertyui"
var str1 = "qwer" // length = 4
let ind = advance(str.startIndex, 6) //equals 6
str1[ind] //fatal error: subscript: subRange extends past String end
str1.removeAtIndex(ind) //fatal error: subscript: subRange extends past String end
Upvotes: 4