WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Day 18 Why ForEach(0...100) gets the error of "No exact matches in call to initializer"

Forums > 100 Days of SwiftUI

I am working on the chanllege 3 of Day 18.

0...100 is equal to 0..<101, right?

When I use ForEach(0...100) to change the tip percentage picker, and I get the error, "No exact matches in call to initializer", why?


No they are not the same 0...100 is a ClosedRange<Int> and the ForEach needs a Range<Int>, however you can change the ForEach by given it id: \.self

Picker("0...100", selection: $picked) {
    ForEach(0...100, id: \.self) { pick in
        Text("Number \(pick)")


Picker("0..<101", selection: $picked) {
    ForEach(0..<101) { pick in
        Text("Number \(pick)")


@NigelGee Thank you so much.


Save 50% in my Black Friday sale.

SAVE 50% To celebrate WWDC22, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.