Ken, he asked for a reference that wouldn't break if the file were moved or
renamed. Neither FSrefs nor URLs have that property.
Brad, what you want is a bookmark (in 10.6) or an alias reference. Aliases
didn't have a Cocoa API until 10.6, but the procedural API isn't hard to use.
--Jens {via iPad}
On Apr 3, 2010, at 3:55 PM, Ken Thomases <[email protected]> wrote:
> 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 ([email protected])
>
> 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/jens%40mooseyard.com
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]