Re: referencing XML Data
Re: referencing XML Data
- Subject: Re: referencing XML Data
- From: Nathan Kinsinger <email@hidden>
- Date: Tue, 16 Sep 2008 14:27:47 -0600
On Sep 16, 2008, at 12:52 PM, Sherm Pendley wrote:
On Tue, Sep 16, 2008 at 7:39 AM, Amy Heavey <email@hidden
> 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 (email@hidden)
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:
This email sent to email@hidden