Re: Images in folder - simple question?
Re: Images in folder - simple question?
- Subject: Re: Images in folder - simple question?
- From: Jeremy Dronfield <email@hidden>
- Date: Wed, 28 Jan 2004 18:48:04 +0000
On 28 Jan 2004, at 4:47 pm, Dominik Gwosdek wrote:
It compiles without errors(yeah) but when I test the forwardButton I
get the following
error message:
2004-01-28 17:45:38.978 DDFCover[2061] NSImageCell's object value must
be an NSImage.
The array returned by -directoryContentsAtPath: includes invisible
files inside the directory (contrary to the impression given by the
documentation). I should have mentioned this in my previous reply. What
you can do is pass the array, object by object, into a second array,
excluding these invisibles (or anything else that isn't an image). For
example, you could do it like this:
NSMutableArray *imageList; //<- set up and alloc'd elsewhere
int counter;
NSArray *filesList = [[NSFileManager defaultManager]
directoryContentsAtPath:myPath];
int fileCount = [filesList count];
for (counter = 0; counter < fileCount; counter++) {
NSString *folderName = [filesList objectAtIndex:counter];
if (![folderName hasPrefix:@"."]) {
[imageList addObject:folderName];
}
}
This excludes those invisibles. A better way would be to change the if
statement to,
if ([folderName hasSuffix:@".jpg"])
Hope this helps.
-Jeremy
========================================
email@hidden
theLocustFarm.net:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.