Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Soccer League Coordinator in Swift

Shawn Wilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Shawn Wilson
iOS Development Techdegree Student 7,049 Points

SIGBART Error on Soccer Coordinator Project

I have completed the code for my SoccerLeague Coordinator project.

Everything seems fine except i am receiving a SIGBART error in this block of code

// Sorting Experienced and Unexperienced Players

    var experiencedPlayers: [[String: AnyObject]] = []
    var unexperiencedPlayers: [[String: AnyObject]] = []

    for player in players {
        if player["hasExperience"] as! Bool == true {
            experiencedPlayers.append(player)
        } else {
            unexperiencedPlayers.append(player)
        }
    }

the error is appearing only in this line if player["hasExperience"] as! Bool == true

here is my dictionary and player array

// Create Players Dicionary
let arnoldWillis: [String: AnyObject] = ["name": "Arnold Willis", "height": "43", "hasExperience": "false", "guardianName": "Claire Willis"]
let benFinkelstein: [String: AnyObject] = ["name": "Ben Finkelstein", "height": "44", "hasExperience": "false", "guardianName": "Aaron and Jill Finkelstein"]
let billBon: [String: AnyObject] = ["name": "Bill Bon", "height": "43", "hasExperience": "true", "guardianName": "Sara and Jenny Bon"]
let chloeAlaska: [String: AnyObject] = ["name": "Chloe Alaska", "height": "47", "hasExperience": "false", "guardianName": "David and Jamie Alaska"]
let diegoSoto: [String: AnyObject] = ["name": "Diego Soto", "height": "41", "hasExperience": "true", "guardianName": "Robin and Sarika Soto"]
let evaGordon: [String: AnyObject] = ["name": "Eva Gordon", "height": "45", "hasExperience": "false", "guardianName": "Wendy and Mike Gordon"]
let herschelKrustofski: [String: AnyObject] = ["name": "Herschel Krustofski", "height": "45", "hasExperience": "true", "guardianName": "Hyman and Rachel Krustofski"]
let jillTanner: [String: AnyObject] = ["name": "Jill Tanner", "height": "36", "hasExperience": "true", "guardianName": "Clara Tanner"]
let joeKavalier: [String: AnyObject] = ["name": "Joe Kavalier", "height": "39", "hasExperience": "false", "guardianName": "Sam and Elaine Kavalier"]
let joeSmith: [String: AnyObject] = ["name": "Joe Smith", "height": "42", "hasExperience": "true", "guardianName": "Jim and Jan Smith"]
let karlSaygan: [String: AnyObject] = ["name": "Karl Saygan", "height": "42", "hasExperience": "true", "guardianName": "Heather Bledsoe"]
let kimmyStein: [String: AnyObject] = ["name": "Kimmy Stein", "height": "41", "hasExperience": "false", "guardianName": "Bill and Hillary Stein"]
let lesClay: [String: AnyObject] = ["name": "Les Clay", "height": "42", "hasExperience": "true", "guardianName": "Wynonna Brown"]
let mattGill: [String: AnyObject] = ["name": "Matt Gill", "height": "40", "hasExperience": "false", "guardianName": "Charles and Sylvia Gill"]
let phillipHelm: [String: AnyObject] = ["name": "Phillip Helm", "height": "44", "hasExperience": "true", "guardianName": "Thomas Helm and Eva Jones"]
let salDali: [String: AnyObject] = ["name": "Sal Dali", "height": "41", "hasExperience": "false", "guardianName": "Gala Dali"]
let sammyAdams: [String: AnyObject] = ["name": "Sammy Adams", "height": "45", "hasExperience": "false", "guardianName": "Jeff Adams"]
let suzaneGreenberg: [String: AnyObject] = ["name": "Suzane Greenberg", "height": "44", "hasExperience": "true", "guardianName": "Henrietta Dumas"]

//create players array
let players = [
            arnoldWillis,
            benFinkelstein,
            billBon,
            chloeAlaska,
            diegoSoto,
            evaGordon,
            herschelKrustofski,
            jillTanner,
            joeKavalier,
            joeSmith,
            karlSaygan,
            kimmyStein,
            lesClay,
            mattGill,
            phillipHelm,
            salDali,
            sammyAdams,
            suzaneGreenberg
]

1 Answer

Shawn Wilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Shawn Wilson
iOS Development Techdegree Student 7,049 Points

So after some troubleshooting the cause of the SIGBART error was how I was using as in the line. i was using as! when i should have been using as?