objective c - Notifications in Multiple Thread iOS -
i have found when want deliver notifications particular threads, there sample apple.
in article, apple suggests using machport monitor thread want process notification.
- (void)processnotification:(nsnotification *)notification { if ([nsthread currentthread] != notificationthread) { // forward notification correct thread. [self.notificationlock lock]; [self.notifications addobject:notification]; [self.notificationlock unlock]; [self.notificationport sendbeforedate:[nsdate date] components:nil from:nil reserved:0]; } else { // process notification here; } }
my question is: if notification , use dispatch_async
process notification, has different appearance?
dispatch_async(dispatch_get_main_queue(), ^{ // process notification here; });
the simple answer : no difference
i noticed apple suggested link updated: 2009-08-18. seems outdated. gcd more powerful , convenient way achieve multi-thread work.
Comments
Post a Comment