String runtime error

  1. 4 years ago

    Joel_Eisenstat

    29 Oct 2019 User since 2016

    For a computed property in a list to format a date - 2019-10-08 00:00:00 to 2019-10-08
    get {
    return _d;
    }
    set {
    _d = value;
    var t = String(value);
    if ( t != null ) {
    date.text = t[0...9];
    }
    }

    Runtime Error
    Out of bounds error: first_index 0 beyond bounds 0...-1

    Can't see why as this works -
    var d = String(TextField1.text);
    TextField2.text = d[0...9];
    related to list ?

  2. Joel_Eisenstat

    29 Oct 2019 User since 2016

    got it, if ( t != null ) { should be if ( t != "" ) {

or Sign Up to reply!