On Sep 16, 2008, at 12:52 PM, Sherm Pendley wrote:

On Tue, Sep 16, 2008 at 7:39 AM, Amy Heavey <[EMAIL PROTECTED] > wrote:

NSArray *customerArray = [custdoc nodesForXPath:@".//customer" error:nil];
               if ([customerArray count]){
                       NSXMLNode *customerNode;
                       for (customerNode in customerArray) {

error: parse error before 'in'

That should be:

    for (NSXMLNode *customerNode in customerArray) {

The for-in statement allows both variants. Using the first version:

NSArray *myArray = [NSArray arrayWithObjects:@"one", @"two", @"three", @"four", nil];
        NSString *testString = @"three";
        
        NSString *myString = nil;
        for (myString in myArray) {
                if ([myString isEqualToString:testString])
                        break;
        }
        NSLog(@"myString = %@", myString);
        
        testString = @"Five";
        
        for (myString in myArray) {
                if ([myString isEqualToString:testString])
                        break;
        }
        NSLog(@"myString = %@", myString);

myString will be valid outside of the for loop context and can be used again. Also, if it finds the testString then myString will have the found value. If the testString is not found then MyString will be nil.

--Nathan



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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]

Reply via email to