ixany
ixany

Reputation: 6040

How to compare a .startIndex of Range<String.Index>

I'm receiving a Range String.Index from the rangeOfString-method.

searchParagraphs = ress.rangeOfString("\n")

now i want to proof the position of the startIndex:

if searchParagraphs?.startIndex == 0 {}

it's not working, because "String.Index? does not conform to protocol _RawOptionSetType". so how can i proof the position/startIndex of a String.Index?

Upvotes: 1

Views: 864

Answers (1)

Antonio
Antonio

Reputation: 72760

To check for the initial position, the correct way is:

if searchParagraphs?.startIndex == ress.startIndex {}

Upvotes: 2

Related Questions