• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: notification when app is moved
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: notification when app is moved


  • Subject: Re: notification when app is moved
  • From: Uli Kusterer <email@hidden>
  • Date: Thu, 17 Jul 2008 23:03:06 +0200

On 17.07.2008, at 12:50, Mitchell Livingston wrote:
I need to pass the location to a c library and reset the location in this library when the application is moved, so I need a way to know when the app is moved.

How can I call it again if I don't know it moved? Waiting until it fails is a bit too late in the process. Sure, chances are the app won't move, but why should it ever fail? Storing it in the library folder is not a real good option.


As someone else said, use a kqueue to detect the app move. I wrote a nice little wrapper class around kqueues for uses like this, find it at

	<http://www.zathras.de/angelweb/sourcecode.htm#UKKQueue>

Watch your application bundle folder with that, and when it notifies you that you've been moved, you can call into your library, passing whatever NSBundle pathForResource: returns then.

Just be aware that Cocoa itself is kinda stupid about coping with the current app's bundle being moved (different from Carbon, funnily enough). So, while your library might still access the correct folders, the rest of your app may still go down in flames. Come to think of it, I'm not even sure whether NSBundle doesn't cache its location, so you might get the old path back. But I guess since the kqueue tells you where it got moved, you could deduce the path anyway.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: notification when app is moved
      • From: Mitchell Livingston <email@hidden>
    • Re: notification when app is moved
      • From: Charles Srstka <email@hidden>
    • Re: notification when app is moved
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >notification when app is moved (From: Mitchell Livingston <email@hidden>)
 >Re: notification when app is moved (From: Omar Qazi <email@hidden>)
 >Re: notification when app is moved (From: Mitchell Livingston <email@hidden>)
 >Re: notification when app is moved (From: Omar Qazi <email@hidden>)
 >Re: notification when app is moved (From: Mitchell Livingston <email@hidden>)

  • Prev by Date: Re: Array help!
  • Next by Date: Re: Sign extension in NSNumber / 10.4 SDK???
  • Previous by thread: Re: notification when app is moved
  • Next by thread: Re: notification when app is moved
  • Index(es):
    • Date
    • Thread