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 trial

iOS

Joel Lithgow
Joel Lithgow
7,414 Points

Error finding domain

All of a sudden on all of my projects I get errors and they all originate from a single error that is in the AppDegelate file, a file I have never been into before and all of a sudden it says

"error = NSError.errorWithDomain("YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)"

with the reason of "errorWithDomain is unavailable"

any reason why this could be happening?

1 Answer

Hi Joel,

This appears to be a simple case that Xcode 6.1 slightly changed the way NSError.errorWithDomain works, simply change it to the below so you have a named parameter defined in the constructor called domain and it should work as normal.

error = NSError.errorWithDomain(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)

Hope that helps.

Joel Lithgow
Joel Lithgow
7,414 Points

It now gives me an error saying "extraneous argument label 'domain:' in call" and I did double check to make sure I'm on 6.1.

Joel Lithgow
Joel Lithgow
7,414 Points

I deleted the errorWithDomain and added the domain: and it works now thanks tho!