Gustavo Payano
Gustavo Payano

Reputation: 45

fatal error: subscript: subRange extends past String end Xcode

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

Answers (2)

Anand
Anand

Reputation: 79

Asynchronous thread causes this problem may occur.

Instead of using DespatchQueue.main.async{}, use DespatchQueue.main.sync{}.

Upvotes: 1

pavxplode
pavxplode

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

Related Questions