Remove UIKit call from -init!1

This commit is contained in:
Hannah Trosi 2016-07-10 21:17:32 -07:00
parent 1d93dbc0b3
commit 2317e17c53

View File

@ -38,6 +38,8 @@
#pragma mark - Lifecycle
// -init is often called off the main thread in ASDK. Therefore it is imperative that no UIKit objects are accessed.
// Examples of common errors include accessing the nodes view or creating a gesture recognizer.
- (instancetype)init
{
_tableNode = [[ASTableNode alloc] init];
@ -50,17 +52,19 @@
_tableNode.dataSource = self;
_tableNode.delegate = self;
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
}
return self;
}
// do any ASDK view stuff in loadView
// -loadView is guaranteed to be called on the main thread and is the appropriate place to
// set up an UIKit objects you may be using.
- (void)loadView
{
[super loadView];
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_photoFeed = [[PhotoFeedModel alloc] initWithPhotoFeedModelType:PhotoFeedModelTypePopular imageSize:[self imageSizeForScreenWidth]];
[self refreshFeed];