Seeing different behaviour when similar code is presented in a Mac app and either a Mac Playground or command line app.
The objective is create an array of range references into a string.
This works in the Playground and Command Line versions but in a Mac app, the same code produces:
For-in loop requires 'Range<String.Index>?' to conform to 'Sequence'; did you mean to unwrap optional?
The Range<String.Index> items in the array are themselves not Sequences.
Unclear why essentially the same code loop is producing an error message when used in the Mac app but no error for the Playground or command line. Nothing defined is an optional.
Experimented with 12.1 and 12.2 - same results so far.
Has anybody seen anything similar?
The objective is create an array of range references into a string.
Code Block /* Define a string */ let source = "Hello" /* Define an array that is a collection of ranges within the string. In this case use the whole range. */ let array = [source.startIndex..<source.endIndex, source.startIndex..<source.endIndex] /* Iterate */ for r in array { ... }
This works in the Playground and Command Line versions but in a Mac app, the same code produces:
For-in loop requires 'Range<String.Index>?' to conform to 'Sequence'; did you mean to unwrap optional?
The Range<String.Index> items in the array are themselves not Sequences.
Unclear why essentially the same code loop is producing an error message when used in the Mac app but no error for the Playground or command line. Nothing defined is an optional.
Experimented with 12.1 and 12.2 - same results so far.
Has anybody seen anything similar?