minor refactoring

This commit is contained in:
Sami Samhuri 2015-05-16 09:08:42 -07:00
parent e305debbe8
commit fb8d71536b

View file

@ -69,11 +69,11 @@ static const NSUInteger SectionPublished = 1;
[self setupTitleView]; [self setupTitleView];
[self setupFontAwesomeIcons]; [self setupFontAwesomeIcons];
self.refreshControl.tintColor = [UIColor whiteColor]; self.refreshControl.tintColor = [UIColor whiteColor];
[self setupNotifications]; [self setupBlogNotifications];
} }
- (void)dealloc { - (void)dealloc {
[self teardownNotifications]; [self teardownBlogNotifications];
} }
- (void)setupTitleView { - (void)setupTitleView {
@ -334,20 +334,24 @@ static const NSUInteger SectionPublished = 1;
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
} }
- (void)setupNotifications { #pragma mark - Blog notificitons
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(postUpdated:) name:PostUpdatedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(draftAdded:) name:DraftAddedNotification object:nil]; - (void)setupBlogNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(draftRemoved:) name:DraftRemovedNotification object:nil]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(publishedPostAdded:) name:PublishedPostAddedNotification object:nil]; [notificationCenter addObserver:self selector:@selector(postUpdated:) name:PostUpdatedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(publishedPostRemoved:) name:PublishedPostRemovedNotification object:nil]; [notificationCenter addObserver:self selector:@selector(draftAdded:) name:DraftAddedNotification object:nil];
[notificationCenter addObserver:self selector:@selector(draftRemoved:) name:DraftRemovedNotification object:nil];
[notificationCenter addObserver:self selector:@selector(publishedPostAdded:) name:PublishedPostAddedNotification object:nil];
[notificationCenter addObserver:self selector:@selector(publishedPostRemoved:) name:PublishedPostRemovedNotification object:nil];
} }
- (void)teardownNotifications { - (void)teardownBlogNotifications {
[[NSNotificationCenter defaultCenter] removeObserver:self name:PostUpdatedNotification object:nil]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[[NSNotificationCenter defaultCenter] removeObserver:self name:DraftAddedNotification object:nil]; [notificationCenter removeObserver:self name:PostUpdatedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:DraftRemovedNotification object:nil]; [notificationCenter removeObserver:self name:DraftAddedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:PublishedPostAddedNotification object:nil]; [notificationCenter removeObserver:self name:DraftRemovedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:PublishedPostRemovedNotification object:nil]; [notificationCenter removeObserver:self name:PublishedPostAddedNotification object:nil];
[notificationCenter removeObserver:self name:PublishedPostRemovedNotification object:nil];
} }
- (void)addPost:(Post *)post toSection:(NSUInteger)section { - (void)addPost:(Post *)post toSection:(NSUInteger)section {