Re: File Extensions Problem

2008-08-29 Thread Uli Kusterer
On 29.08.2008, at 02:12, Graham Cox wrote: Well, that was me. But I do see the error of my ways... I guess it was Michael Ash's comment that NSArray *could* change its storage half way through enumeration (if the collection were mutated) that woke me up. I suspect it would only do this if

Re: File Extensions Problem

2008-08-29 Thread Michael Ash
On Thu, Aug 28, 2008 at 9:50 PM, Gerriet M. Denkmann [EMAIL PROTECTED] wrote: While if fully agree with you about valid assumptions and so, I am still wondering what is the disadvantage of forgetting about NSEnumerator, Fast Enumeration and the like and simply doing: unsigned count = [ array

Re: File Extensions Problem

2008-08-29 Thread Gerriet M. Denkmann
On Fri, 29 Aug 2008 12:13:34 -0400, Michael Ash [EMAIL PROTECTED] wrote: On Thu, Aug 28, 2008 at 9:50 PM, Gerriet M. Denkmann [EMAIL PROTECTED] wrote: While if fully agree with you about valid assumptions and so, I am still wondering what is the disadvantage of forgetting about

Re: File Extensions Problem

2008-08-29 Thread Greg Parker
Gerriet Denkmann wrote: While if fully agree with you about valid assumptions and so, I am still wondering what is the disadvantage of forgetting about NSEnumerator, Fast Enumeration and the like and simply doing: unsigned count = [ array count ]; if ( count == 0 ) return; for( unsigned i =

Re: File Extensions Problem

2008-08-28 Thread Ingvar Nedrebo
Adil, I use NSWorkspace and UTI types to do this, as in the code below. Look at the UTI hierarchy and replace public.movie in the code with whichever type covers the files you're interested in. -(NSArray *)mediaFilesInFolder:(NSString *)folderPath { NSMutableArray * files =

Re: File Extensions Problem

2008-08-28 Thread Michael Ash
On Wed, Aug 27, 2008 at 6:59 PM, R.L. Grigg [EMAIL PROTECTED] wrote: Hmm, I guess the wrinkle in this particular case is if the contract doesnt specify something that the programmer assumes to be safe to do (like enumerating backwards), how can you know how to implement your end? I guess there

Re: File Extensions Problem

2008-08-28 Thread Ken Thomases
On Aug 27, 2008, at 5:59 PM, R.L. Grigg wrote: Hmm, I guess the wrinkle in this particular case is if the contract doesnt specify something that the programmer assumes to be safe to do (like enumerating backwards), how can you know how to implement your end? Enumerating NSArrays

Re: File Extensions Problem

2008-08-28 Thread Graham Cox
On 29 Aug 2008, at 4:28 am, Ken Thomases wrote: On Aug 27, 2008, at 5:59 PM, R.L. Grigg wrote: Hmm, I guess the wrinkle in this particular case is if the contract doesnt specify something that the programmer assumes to be safe to do (like enumerating backwards), how can you know how to

Re: File Extensions Problem

2008-08-28 Thread Gerriet M. Denkmann
On 28 Aug 2008 11:52:46 -0400, Michael Ash [EMAIL PROTECTED] wrote: On Wed, Aug 27, 2008 at 6:59 PM, R.L. Grigg [EMAIL PROTECTED] wrote: Hmm, I guess the wrinkle in this particular case is if the contract doesnt specify something that the programmer assumes to be safe to do (like

Re: File Extensions Problem

2008-08-27 Thread R.L. Grigg
On Aug 22, 2008, at 4:24 PM, Thomas Engelmeier wrote: Am 22.08.2008 um 17:23 schrieb Michael Ash: On Fri, Aug 22, 2008 at 6:23 AM, Graham Cox [EMAIL PROTECTED] wrote: safe to delete items in the array at or higher than the current index. By the definition of an array, removing an item only

Re: File Extensions Problem

2008-08-27 Thread Ken Thomases
On Aug 27, 2008, at 1:50 PM, R.L. Grigg wrote: This is interesting. Correct me if I'm wrong but as a newb what I'm getting from all this is if I design my code around implementation specifics of frameworks or even the language I'm using, that equates to a unrobust design, cuz if the

Re: File Extensions Problem

2008-08-27 Thread Charles Srstka
On Aug 27, 2008, at 1:50 PM, R.L. Grigg wrote: On Aug 22, 2008, at 4:24 PM, Thomas Engelmeier wrote: Am 22.08.2008 um 17:23 schrieb Michael Ash: On Fri, Aug 22, 2008 at 6:23 AM, Graham Cox [EMAIL PROTECTED] wrote: safe to delete items in the array at or higher than the current index. By

Re: File Extensions Problem

2008-08-27 Thread R.L. Grigg
On Aug 27, 2008, at 12:19 PM, Ken Thomases wrote: On Aug 27, 2008, at 1:50 PM, R.L. Grigg wrote: This is interesting. Correct me if I'm wrong but as a newb what I'm getting from all this is if I design my code around implementation specifics of frameworks or even the language I'm using,

Re: File Extensions Problem

2008-08-27 Thread Phil
On Thu, Aug 28, 2008 at 10:59 AM, R.L. Grigg [EMAIL PROTECTED] wrote: Hmm, I guess the wrinkle in this particular case is if the contract doesnt specify something that the programmer assumes to be safe to do (like enumerating backwards), how can you know how to implement your end? I guess

Re: File Extensions Problem

2008-08-24 Thread Andrew Merenbach
On Aug 21, 2008, at 11:29 PM, Adil Saleem wrote: Hi, I want to display in a tableview, list of all media files (audio, video files) present in a certain directory. Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function

File Extensions Problem

2008-08-22 Thread Adil Saleem
Hi, I want to display in a tableview, list of all media files (audio, video files) present in a certain directory. Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function directoryContentsAtPath I get the list, but the problem is that

Re: File Extensions Problem

2008-08-22 Thread Michael Dautermann
On Aug 22, 2008, at 2:29 AM, Adil Saleem wrote: Hi, I want to display in a tableview, list of all media files (audio, video files) present in a certain directory. Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function

Re: File Extensions Problem

2008-08-22 Thread Andrew Merenbach
On Aug 22, 2008, at 12:10 AM, Michael Dautermann wrote: On Aug 22, 2008, at 2:29 AM, Adil Saleem wrote: Hi, I want to display in a tableview, list of all media files (audio, video files) present in a certain directory. Currently what i am doing is that i am getting the file names in an

Re: File Extensions Problem

2008-08-22 Thread Graham Cox
On 22 Aug 2008, at 5:22 pm, Andrew Merenbach wrote: Hi! It appears that you're removing an object from a mutable array while enumerating, so that will unfortunately not work. To modify your concept: NSMutableArray *myMutableArray = [myOriginalArray copy]; Or just use

Re: File Extensions Problem

2008-08-22 Thread Phil
On Fri, Aug 22, 2008 at 7:28 PM, Graham Cox [EMAIL PROTECTED] wrote: Or just use reverseObjectEnumerator. Removing the current iteration item from the array while iterating backwards is OK. Even going backwards, it's still not ok... From the -reverseObjectEnumerator 'special considerations'

Re: File Extensions Problem

2008-08-22 Thread Phil
On Fri, Aug 22, 2008 at 6:29 PM, Adil Saleem [EMAIL PROTECTED] wrote: Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function directoryContentsAtPath I get the list, but the problem is that it get all the files. I want only those files

Re: File Extensions Problem

2008-08-22 Thread Graham Cox
On 22 Aug 2008, at 7:10 pm, Phil wrote: From the -reverseObjectEnumerator 'special considerations' section of the documentation: When you use this method with mutable subclasses of NSArray, you must not modify the array during enumeration. You shouldn't go modifying the array in general,

Re: File Extensions Problem

2008-08-22 Thread Phil
On Fri, Aug 22, 2008 at 10:23 PM, Graham Cox [EMAIL PROTECTED] wrote: You shouldn't go modifying the array in general, for sure. But the special case of modification by deleting the last item in the array is safe, and always will be. In fact deleting any item with a higher index than current

Re: File Extensions Problem

2008-08-22 Thread Adam R. Maxwell
On Aug 22, 2008, at 2:27 AM, Phil wrote: On Fri, Aug 22, 2008 at 6:29 PM, Adil Saleem [EMAIL PROTECTED] wrote: Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function directoryContentsAtPath I get the list, but the problem is that it

Re: File Extensions Problem

2008-08-22 Thread Michael Ash
On Fri, Aug 22, 2008 at 6:23 AM, Graham Cox [EMAIL PROTECTED] wrote: -reverseObjectEnumerator is no different, because it lets you access each object in the receiver, in order, from the element at the highest index down to the element at index 0. This statement will hold true for any future

Re: File Extensions Problem

2008-08-22 Thread Andrew Merenbach
On Aug 22, 2008, at 8:23 AM, Michael Ash wrote: On Fri, Aug 22, 2008 at 6:23 AM, Graham Cox [EMAIL PROTECTED] wrote: -reverseObjectEnumerator is no different, because it lets you access each object in the receiver, in order, from the element at the highest index down to the element at

Re: File Extensions Problem

2008-08-22 Thread Sherm Pendley
On Fri, Aug 22, 2008 at 11:39 AM, Andrew Merenbach [EMAIL PROTECTED] wrote: To build on this, doesn't fast enumeration (Leopard-only, of course) raise an exception if a value is modified while the enumeration is running? (Not tested personally by me, but building upon an earlier thread from a

Re: File Extensions Problem

2008-08-22 Thread Charles Srstka
On Aug 22, 2008, at 10:39 AM, Andrew Merenbach wrote: To build on this, doesn't fast enumeration (Leopard-only, of course) raise an exception if a value is modified while the enumeration is running? (Not tested personally by me, but building upon an earlier thread from a little while

Re: File Extensions Problem

2008-08-22 Thread Thomas Engelmeier
Am 22.08.2008 um 17:23 schrieb Michael Ash: On Fri, Aug 22, 2008 at 6:23 AM, Graham Cox [EMAIL PROTECTED] wrote: safe to delete items in the array at or higher than the current index. By the definition of an array, removing an item only affects the indexes of objects with equal or