Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Gutowski
4,082 PointsXcode won't compile code fully (8.0, 8S128d)
For some reason Xcode will just hang when trying to run my code.
struct Friend {
let name: String
let age: String
let address: String?
}
enum FriendError: ErrorProtocol {
case InvalidData(String)
}
func createFriendFromJSON(dict: [String : String]) throws -> Friend {
guard let name = dict["name"] else {
throw FriendError.InvalidData("Name key fails")
}
guard let age = dict["age"] else {
throw FriendError.InvalidData("Age key fails")
}
let address = dict["address"]
return Friend(name: name, age: age, address: address)
}
func sendMessageToFriend(friend: Friend, message: String) {}
let response = ["name": "Pasan", "ages": "27", "address": "someAddress"]
do {
let friend = try createFriendFromJSON(dict: response)
sendMessageToFriend(friend: friend, message: "")
} catch FriendError.InvalidData(let key) {
print(key)
}
I just keep getting the spinner as if Xcode is trying to compile but isn't completing. Any ideas?
2 Answers
Trent Christofferson
18,846 Pointsenum FriendError: ErrorProtocol { case InvalidData(String) }
Change ErrorProtocol to ErrorType
I hope this helps you!
Kevin Gutowski
4,082 PointsHi Trent! ErrorType is changed to ErrorProtocol in the new version of Swift (3.0).
Trent Christofferson
18,846 Pointswere not on swift 3 right now
Chris Lopez
8,155 PointsErrorType is now Error in the latest version of swift 3
Kevin Gutowski
4,082 PointsKevin Gutowski
4,082 PointsI'm not getting any complier errors. In fact, I don't have any errors at all. It just hangs.