3

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.

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

Comments

1

Asynchronous thread causes this problem may occur.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.