Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Watching folders for new files and event handling based on that?



On 10.08.2007, at 23:42, Alastair Houghton wrote:
For many purposes you can avoid needing this functionality completely with a little thought. For instance, say you're displaying files to the user (like Finder does). In that case, a good technique is to refresh your view every time the user activates your window. That way, if they switch to another app and save something, you're guaranteed to notice it at just the right time.

God no, please don't take the 10.0 Finder's approach ... it has issues:


1) A user may be waiting for the download to finish with your window open, then decide to play a round of Mine S^H^H^H Solit^H^H^H Chess, glancing over at your background window occasionally to see whether the download's finished. If you don't update until it's activated, your window will not update correctly.

2) #1 can even apply in your application, if you have several windows open, the non-current ones will not update.

3) This is only possible if your view will already be open. With an app like Hazel, that generally watches your folders in the background, that won't work.

4) This can lead to big confusion: Imagine the user double-clicks in an inactive window. This activates your window and updates its contents, inserting a new file in the list above the entry you double- clicked. Suddenly your list item has moved, and you end up opening the wrong file. This can also happen with live updates, but generally the user does something to cause a file system change (in another app or another window), so at the moment your window updates, the user will be looking elsewhere. OTOH, if your window updates as it's activated, you're coalescing all changes towards the point where the user is actually interested in and about to use your window.

In short: You'll just end up annoying your users. Use real file system notifications like kqueues, or use polling and only update a little *after* window activation (performSelector:withDelay: is your friend), and only after a bit of user-idleness. Just try opening a smart folder in Finder that contains lots of items from a slow disk. Stuff will constantly be moving around and therefore you can't click anything until all items have been loaded, even if your item of interest was loaded as the fifth one.

Cheers,
-- M. Uli Kusterer
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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Watching folders for new files and event handling based on that? (From: Tim Perrett <email@hidden>)
 >Re: Watching folders for new files and event handling based on that? (From: Alastair Houghton <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.