detect a changed file? (as fast as possible)

Hi

i tried to make a communication between a regular app (EvoCam) that loads a script which in turn “pokes” my ASOC app to run a function.
i couldn’t do it.

anyway, all these different apps (evocam, applemail, bluephoneelite) should ever do, is pass a number/state (activated, deactivated, triggered) to my own app.

well i figured it is too complicated to make my application “listening” directly.

so i was thinking…

what about a man in the middle? or more suitable, a file in the middle.

so, e.g. evocam writes into a plist, and as soon as the file gets changed, my own app should notice this, read out the value from that plist and act accordingly.

now, basically that is possible if i make a loop in my applescript that always checks this file for a change.
however, this would mean, that the app would always be in a loop and take a lot of resource.

i was wondering if it is somehow possible to “watch” a file and run a function inside my ASOC app?

What you probably want is an NSTimer, to call something the shell’s ls command every few seconds – there’s no built-in ObjC method for it.

There’s also a set of ObjC classes that encapsulate some of the functionality you’re after – Google for UKKQueue. Using it from ASObjC isn’t exactly obvious, but it’s also not hard.