Reputation: 55825
I have a very simple for loop that is giving me troubles. This code ran without issue in Xcode beta 4, but in beta 5 it is complaining that the half open interval (and the closed interval) don't conform to BooleanType. What has changed, why doesn't this work anymore, or is this a bug?
for let i = 0; i..<cellCount!; ++i {
//do stuff
}
cellCount
is defined as an optional Int
property:
private var cellCount: Int?
I have tried storing the cellCount into a non-optional constant but the issue still remains:
let numberOfCells: Int = cellCount!
for let i = 0; i..<numberOfCells; ++i {
//do stuff
}
I see in the Release Notes a lot has changed with Ranges, but nothing seems to be relevant to this issue.
Upvotes: 1
Views: 1026
Reputation: 3971
Does this have anything to do with HalfOpenInterval? I thought the struct is Range? If you use HalfOpenInterval in for-in, it will not work. It is not of protocol SequenceType
Upvotes: 1
Reputation: 94753
Ranges are meant to be used in a for in
loop:
for i in 0..<cellCount! {
// do stuff
}
Upvotes: 5