source:http://mjtsai.com/blog/2014/11/21/ios-ipc-via-nsfilecoordinator-and-nsfilepresenter/
Why every time I think of something that has been researched by others. ⊙﹏⊙ b Khan
Tom Harrington:
There ' s still no full IPC mechanism on IOS.? NSDistributedNotification
? Hasn ' t made the jump from OS X to IOS and probably never would. But file coordination and presentation can serve the same purpose, as long as the apps use the same app group.
When I am adding file coordination and presentation to my Demo app, I realized that they could also is used for Notifi Cations between an app and its extensions. If One of them does a coordinated write while the and the other are using a file presenter for the file, the call Topresenteditemdidchange
? happens almost instantly. The Notification is the whole purpose of the It makes sense it would work this method. I want to is notified if a specific file changes, and that's how I get the notification.
But you don ' t need-care about the file contents to being interested in notifications. If you just want a notification, choose a file name and use it as the notification mechanism. Any time one process needs to notify the other and make a change to the file. The other would get a file presenter call, and the notification are complete. It feels sort of a hack but really this is exactly how the API was designed to work.
Update (2014-11-22):? Apple TN2408? (via?) Janapotheker):
using file coordination in the app extension to access a container gkfx with its contain ing app may result in a deadlock. This was usually the case if a process is suspended mid coordinated I/O. This can is more prevalent on IOS where most apps would be suspended after a short period of time after being moved to the Background. Extensions should use alternatives to file coordination.
[...]
Regardless of this issue, the containing app (and all applications) should properly use background task assertions Arou nd file operations they require completed in a GKFX container (with or without extensions). This includes all writes or deletions. Such a process might still is killed by Jetsam and at a much lower frequency.
?
[Turn]ios IPC via Nsfilecoordinator and Nsfilepresenter