Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: subscript: subRange extends past String end Xcode

Tags:

xcode

ios

swift

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.

like image 894
Gustavo Payano Avatar asked Dec 29 '25 15:12

Gustavo Payano


1 Answers

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
like image 80
pavxplode Avatar answered Jan 01 '26 05:01

pavxplode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!