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 Intermediate Swift Object Initialization Required Initializers

how do I get Xcode to help me for required initialiser's?

How do I setup Xcode so that it will report and error in the IDE when I am missing a required initializer?

At the moment Xcode does through an error and does report it as follows, but doesn't provide a fix in the IDE. ie. the red button with a fix attached?

Any help would be appreciated.

Playground execution failed: error: Initialization.xcplaygroundpage:202:1: error: 'required' initializer 'init(coder:)' must be provided by subclass of 'UIViewController' }

2 Answers

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

Xcode can indeed help you with this, here's two ways of applying Xcode auto fixes :

  1. Tap on the red error indicator that marks the error in the line number column. If Xcode can provide a quick fix, it will suggest it here. Tap on the fix as well and it will insert/change the code correspondingly.

  2. Use shortcuts to apply auto fixes

Ctrl + Cmd + f // fixes all errors in scope
Ctrl + Cmd + ' // fixes next error
Ctrl + Cmd + " // fixes prev error

Hope that helps :)

Thanks Martin appreciate your help