Archive for category XPC

Replacement for NSTimer

I’ve been looking around for a NSTimer replacement. Mostly to avoid needing to make sure the timer is running on a runloop and that your running the timer in a suitable mode. All of the replacements use gcd and queues.

I’ve found a number of possible replacements, but one in particular looks like the one to go for. The three others use the main thread and I want to get away from the main thread. It is easy enough to send a update ui message back to the main thread once the required work has been done.

I like the simplicity of this NSTimer replacement, it doesn’t require a new class instead everything is wrapped up nicely in a block and it will keep on firing until the object that it fires the doSomething message to no longer exists. What I don’t like is that the code is run on the main thread.

This nice simple timer class is also good, but it also runs on the main thread.

Finally I come to MSWeakTimer. I’m in the process of including it in my project so I’ll report back when I’m done. It is more complicated than the other timers but it is not dependent on the runloop or the main queue.

Report Back

MSWeakTimer seems to be working as expected. I needed to make a couple of small changes to get rid of warnings. I’ve got no warnings in my current project and I’m hoping to keep it that way.

Tags: , , ,

LaunchAgents and XPC

Getting a LaunchAgent up and running

I’ve had quite a struggle getting a LaunchAgent with the features I want working. This blog piece I hope will be your short cut to avoid wasting the amount of time I have getting my LaunchAgent working. Much of this blog piece is a gripe about the unclear documentation.

You can download my example LaunchAgent project from GitHub.

Please read the file and you can then play around with the project.

A LaunchAgent belongs to a collection of executables that includes, LaunchDaemons, LoginItems and XPC Services from now on I’ll call them service providers. Service providers add functionality or do work for an application or the operating system. They mostly don’t display any User Interface (UI). LoginItems can display UI and can be full applications, LaunchDaemons can’t display any UI and the same goes for XPC services, LaunchAgents can display UI though it is not recommended.
Read the rest of this entry »


Cocoa Interprocess Communication with XPC

WWDC 2012 Session 308

Different ways of communicating between the different parts of a multi-process application, otherwise known as Interprocess Communication (IPC).

  • Mach messages
  • Sockets
  • Distributed Objects
  • XPC

Read the rest of this entry »

Tags: ,