Re: Strange NSEnumerator Behavior
Re: Strange NSEnumerator Behavior
- Subject: Re: Strange NSEnumerator Behavior
- From: Eric Ocean <email@hidden>
- Date: Thu, 14 Oct 2004 18:48:47 -0700
You appear to have a spurious semicolon after your while statement:
while(filePath = (NSString *)[fileEnumerator nextObject]); <------
There's the semicolon
So, what happens is your while statement loops until filePath is nil,
doing nothing, and then it prints your log statement.
Regards,
Eric Ocean
On Oct 14, 2004, at 6:06 PM, Daniel Todd Currie wrote:
I have the following block of code:
NSLog(@"filenamesArray = %@, count = %i", filenamesArray,
[filenamesArray count]);
NSEnumerator *fileEnumerator = [(NSArray *)filenamesArray
objectEnumerator];
id filePath;
filePath = (NSString *)[fileEnumerator nextObject];
NSLog(@"filePath = %@", filePath);
Which yields this run log:
2004-10-15 09:58:57.697 myApp[6088] filenamesArray = <CFArray
0x34af80 [0xa01900e0]>{type = mutable-small, count = 1, values = (
0 : <CFString 0x395010 [0xa01900e0]>{contents =
"/Users/dtcurrie/Documents/Downloads/Rax.dmg"}
)}, count = 1
2004-10-15 09:58:57.697 myApp[6088] filePath =
/Users/dtcurrie/Documents/Downloads/Rax.dmg
As expected, this works fine.
However the following block of code:
NSLog(@"filenamesArray = %@, count = %i", filenamesArray,
[filenamesArray count]);
NSEnumerator *fileEnumerator = [(NSArray *)filenamesArray
objectEnumerator];
id filePath;
while(filePath = (NSString *)[fileEnumerator nextObject]);
{
NSLog(@"filePath = %@", filePath);
}
Yields this run log:
2004-10-15 09:59:40.172 myApp[6098] filenamesArray = <CFArray
0x314bd0 [0xa01900e0]>{type = mutable-small, count = 1, values = (
0 : <CFString 0x38b6c0 [0xa01900e0]>{contents =
"/Users/dtcurrie/Documents/Downloads/Rax.dmg"}
)}, count = 1
2004-10-15 09:59:40.172 myApp[6098] filePath = (null)
What could possibly be going on here? Am I just overlooking something
obvious? I have never had trouble with NSEnumerators in the past...
Thanks in advance,
-- DTC
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden