Watch App Generated Code Says to Use awakeWithContext: Instead of Init
| Originator: | sethfri | ||
| Number: | rdar://19726147 | Date Originated: | 2/4/2015 |
| Status: | Open | Resolved: | No |
| Product: | Developer Tools | Product Version: | Xcode 6.2 beta 5 |
| Classification: | UI/Usability | Reproducible: | Always |
Summary:
When creating a new Watch App target, InterfaceController.{h,m} are created for you. awakeWithContext: is stubbed out with a comment that says "// Configure interface objects here.". However, according to the documentation, init should be used for setting up and configuring interface objects, and awakeWithContext: should only be used to finish setting things up.
To developers new to WatchKit (a.k.a. everyone), this could be very misleading, encouraging use of awakeWithContext: for all setup.
Steps to Reproduce:
1. Create new iOS app project
2. Create new Watch app target, embedded in the iOS app
Expected Results:
The generated code should have "// Configure interface objects here." in the stubbed out init method.
Actual Results:
The generated code has "// Configure interface objects here." in the stubbed out awakeWithContext: method.
Version:
Xcode 6.2 beta 5, OS X 10.10.2
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Apple Developer Relations
Engineering has provided the following feedback regarding this issue:
We believe this issue has been addressed through changes on our side.
https://developer.apple.com/library/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/awakeWithContext:
Please let us know whether the issue is resolved for you by updating your bug report.
My Reply
Hello, and thanks for the reply! This is definitely a lot better, but there's still a line in the init documentation that makes this confusing:
"After calling super, you can use the objects in those properties to prepare your user interface, but use the awakeWithContext: method for the bulk of your interface initialization."
"The bulk of your interface initialization" in awakeWithContext: makes it sound as though some interface initialization is appropriate for init. It's not clear what the drawbacks are of preparing the user interface in init, or what configuration qualifies for init and what doesn't.