Re: Convert NSString to FSRef

2008-03-17 Thread Sean McBride
On 3/15/08 3:04 PM, Kevin Dixon said: >I'm trying to write a method that will convert a NSString containing a >file system URL to an FSRef > > *SNIP* > >Also, is there a better way to accomplish this? Yes, use the NDAlias classes which provide all sort of useful code to convert to and from: url,

Re: Convert NSString to FSRef

2008-03-17 Thread Kevin Dixon
Thanks for all the feed back, its been most helpful. -Kevin > > On Mar 15, 2008, at 12:04 PM, Kevin Dixon wrote: > >> I'm trying to write a method that will convert a NSString containing a >> file system URL to an FSRef with the following code >> >> - (FSRef)stringToFSRef: (NSString*)filePath { >

Re: Convert NSString to FSRef

2008-03-16 Thread Adam R. Maxwell
On Mar 16, 2008, at 11:15 AM, Michael Ash wrote: On Sun, Mar 16, 2008 at 5:41 AM, Nir Soffer <[EMAIL PROTECTED]> wrote: On Mar 16, 2008, at 10:11, stephen joseph butler wrote: On Sat, Mar 15, 2008 at 2:04 PM, Kevin Dixon <[EMAIL PROTECTED]> wrote: Also, is there a better way to accompl

Re: Convert NSString to FSRef

2008-03-16 Thread Michael Ash
On Sun, Mar 16, 2008 at 5:41 AM, Nir Soffer <[EMAIL PROTECTED]> wrote: > > On Mar 16, 2008, at 10:11, stephen joseph butler wrote: > > > On Sat, Mar 15, 2008 at 2:04 PM, Kevin Dixon <[EMAIL PROTECTED]> wrote: > > > >> Also, is there a better way to accomplish this? > > > > > > There are a lo

Re: Convert NSString to FSRef

2008-03-16 Thread Stuart Malin
Jens, Thank you for pointing these out. I provided the info I did because I hadn't seen anyone else reply to Kevin with detailed code suggestions, but rather, vague suggestions. I stated clearly that my suggestion was from a Cocoa perspective on how to convert NSString to bytes, and were

Re: Convert NSString to FSRef

2008-03-16 Thread Jens Alfke
On 15 Mar '08, at 11:49 PM, Stuart Malin wrote: 1: I have never worked with CF functions before Then, with all due respect, you might want to hold off giving advice to others until you get some more experience with it. CF can be tricky to work with. (1) Both of your examples leak memory

Re: Convert NSString to FSRef

2008-03-16 Thread Jean-Daniel Dupas
Le 16 mars 08 à 07:49, Stuart Malin a écrit : Kevin, Here's two variants that you can start to work with. Use the first one if it works. The second one is a more roundabout way of getting the NSString to bytes. Two disclaimers: 1: I have never worked with CF functions before, but have b

Re: Convert NSString to FSRef

2008-03-16 Thread Nir Soffer
On Mar 16, 2008, at 10:11, stephen joseph butler wrote: On Sat, Mar 15, 2008 at 2:04 PM, Kevin Dixon <[EMAIL PROTECTED]> wrote: Also, is there a better way to accomplish this? There are a lot of buggy or unnecessarily complex answers in this thread. Use the code at the bottom of this Co

Re: Convert NSString to FSRef

2008-03-16 Thread stephen joseph butler
On Sat, Mar 15, 2008 at 2:04 PM, Kevin Dixon <[EMAIL PROTECTED]> wrote: > Also, is there a better way to accomplish this? There are a lot of buggy or unnecessarily complex answers in this thread. Use the code at the bottom of this CocoaDev link and be done with it: http://www.cocoadev.com/index

Re: Convert NSString to FSRef

2008-03-15 Thread Stuart Malin
Kevin, Here's two variants that you can start to work with. Use the first one if it works. The second one is a more roundabout way of getting the NSString to bytes. Two disclaimers: 1: I have never worked with CF functions before, but have been doing a bit of string-data-bytes manipulati

Re: Convert NSString to FSRef

2008-03-15 Thread Adam R. Maxwell
On Mar 15, 2008, at 12:34 PM, Keith Duncan wrote: -cString has been deprecated for a very long time; it's better to use UTF8String. Not all file systems support UTF8, you should use - fileSystemRepresentation instead for compatability. For some APIs, but not in this case. The OP is creat

Re: Convert NSString to FSRef

2008-03-15 Thread Keith Duncan
-cString has been deprecated for a very long time; it's better to use UTF8String. Not all file systems support UTF8, you should use - fileSystemRepresentation instead for compatability. Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Re: Convert NSString to FSRef

2008-03-15 Thread Jean-Daniel Dupas
Le 15 mars 08 à 20:04, Kevin Dixon a écrit : I'm trying to write a method that will convert a NSString containing a file system URL to an FSRef with the following code - (FSRef)stringToFSRef: (NSString*)filePath { FSRef output; CFStringRef cfFilePath = CFStringCreateWithCString

Re: Convert NSString to FSRef

2008-03-15 Thread Adam R. Maxwell
On Mar 15, 2008, at 12:04 PM, Kevin Dixon wrote: I'm trying to write a method that will convert a NSString containing a file system URL to an FSRef with the following code - (FSRef)stringToFSRef: (NSString*)filePath { FSRef output; CFStringRef cfFilePath = CFStringCreateWithCS