On Apr 3, 2010, at 5:20 PM, Brad Stone wrote:

> I want to store a reference to a file in an ivar that will allow the user to 
> change the file's name and/or the directory (i.e. the path) and still allow 
> me to access it.  I don't want to create a file (like an ailas).  I need to 
> store the file reference in a variable so I can open the file no matter where 
> the user moves it or renames it.

FSRefs have the property you desire.  As of Snow Leopard, though, the new 
recommended technique is to use a file reference NSURL.  Check the NSURL 
documentation and also:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/LowLevelFileMgmt/Articles/FileManagementNSURL.html


Note that an alias _record_ is different from an alias _file_.  An alias record 
is data in memory and is suitable for this purpose, but perhaps overkill.

As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
but, again, it's probably overkill.  (Both alias records and bookmark data are 
more suitable if the reference is to be persisted for use by a later process.  
Also, both can apply more robust searching heuristics to find an appropriate 
file even if it isn't the original.  For example, if the original is deleted 
and replaced with a new file of the same name.)

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to