diff options
author | stuconnolly <stuart02@gmail.com> | 2010-10-20 20:08:08 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-10-20 20:08:08 +0000 |
commit | c92776958cb5d5fca8f165e9bac043e5a91521dc (patch) | |
tree | 9146f7a5f62b799eadf8126f3b3708284e940fd8 /Frameworks/MCPKit/Support files/NSNotificationAdditions.m | |
parent | 3b92b30ca625eff33df49b538e3c4f2da7a9cf09 (diff) | |
download | sequelpro-c92776958cb5d5fca8f165e9bac043e5a91521dc.tar.gz sequelpro-c92776958cb5d5fca8f165e9bac043e5a91521dc.tar.bz2 sequelpro-c92776958cb5d5fca8f165e9bac043e5a91521dc.zip |
Split MCPConnection's delegate methods into it's own protocol.
Diffstat (limited to 'Frameworks/MCPKit/Support files/NSNotificationAdditions.m')
-rw-r--r-- | Frameworks/MCPKit/Support files/NSNotificationAdditions.m | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m index f27a4d5c..d615231e 100644 --- a/Frameworks/MCPKit/Support files/NSNotificationAdditions.m +++ b/Frameworks/MCPKit/Support files/NSNotificationAdditions.m @@ -24,50 +24,64 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "NSNotificationAdditions.h" -#import <pthread.h> +#import "pthread.h" @implementation NSNotificationCenter (NSNotificationCenterAdditions) -- (void) postNotificationOnMainThread:(NSNotification *) notification { - if( pthread_main_np() ) return [self postNotification:notification]; +- (void)postNotificationOnMainThread:(NSNotification *)notification +{ + if (pthread_main_np()) return [self postNotification:notification]; + [self postNotificationOnMainThread:notification waitUntilDone:NO]; } -- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait { - if( pthread_main_np() ) return [self postNotification:notification]; - [[self class] performSelectorOnMainThread:@selector( _postNotification: ) withObject:notification waitUntilDone:wait]; +- (void)postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)wait +{ + if (pthread_main_np()) return [self postNotification:notification]; + + [[self class] performSelectorOnMainThread:@selector(_postNotification:) withObject:notification waitUntilDone:wait]; } -+ (void) _postNotification:(NSNotification *) notification { ++ (void)_postNotification:(NSNotification *)notification +{ [[self defaultCenter] postNotification:notification]; } -- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object { - if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:nil]; +- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object +{ + if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:nil]; + [self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO]; } -- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo { - if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo]; +- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo +{ + if(pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; + [self postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; } -- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait { - if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo]; +- (void)postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)wait +{ + if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:3]; - if( name ) [info setObject:name forKey:@"name"]; - if( object ) [info setObject:object forKey:@"object"]; - if( userInfo ) [info setObject:userInfo forKey:@"userInfo"]; + + if (name) [info setObject:name forKey:@"name"]; + if (object) [info setObject:object forKey:@"object"]; + if (userInfo) [info setObject:userInfo forKey:@"userInfo"]; - [[self class] performSelectorOnMainThread:@selector( _postNotificationName: ) withObject:info waitUntilDone:wait]; + [[self class] performSelectorOnMainThread:@selector(_postNotificationName:) withObject:info waitUntilDone:wait]; [info release]; } -+ (void) _postNotificationName:(NSDictionary *) info { ++ (void)_postNotificationName:(NSDictionary *)info +{ NSString *name = [info objectForKey:@"name"]; + id object = [info objectForKey:@"object"]; + NSDictionary *userInfo = [info objectForKey:@"userInfo"]; [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; |