objective c - Notifications in Multiple Thread iOS -


i have found when want deliver notifications particular threads, there sample apple.

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/notifications/articles/threading.html#//apple_ref/doc/uid/20001289-cegjfdfg

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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -