Created
April 9, 2013 09:45
-
-
Save maxhuk/5344469 to your computer and use it in GitHub Desktop.
Useful when sending notifications from a worker queue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSNotificationCenter+GCD.h | |
// | |
// Created by Maksym Huk on 10/30/12. | |
// Copyright (c) 2012 Maksym Huk. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSNotificationCenter (GCD) | |
- (void)postNotificationOnMainQueueName:(NSString *)aName object:(id)anObject; | |
- (void)postNotificationOnMainQueueName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSNotificationCenter+GCD.m | |
// | |
// Created by Maksym Huk on 10/30/12. | |
// Copyright (c) 2012 Maksym Huk. All rights reserved. | |
// | |
#import "NSNotificationCenter+GCD.h" | |
@implementation NSNotificationCenter (GCD) | |
- (void)postNotificationOnMainQueueName:(NSString *)aName object:(id)anObject | |
{ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[self postNotificationName:aName object:anObject]; | |
}); | |
} | |
- (void)postNotificationOnMainQueueName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo | |
{ | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[self postNotificationName:aName object:anObject userInfo:aUserInfo]; | |
}); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment