Hi everyone
I am able to add to my array, but if i have two objects added to the array, the object at index 0 will be totally replaced by object at index 1...which the last object to be added.
Code:
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
//aTaxiQuery = [[TaxiQuery alloc] init];
if ([elementName isEqualToString:@"retrieveTaxiQuery"])
{
aTaxiQuery = [[TaxiQuery alloc] init];
}
else if ([elementName isEqualToString:@"queryID"])
{
NSLog(@"QUERYID %i", [self.xmlElementValue intValue]);
[aTaxiQuery setQueryID:[self.xmlElementValue intValue]];
//aTaxiQuery.queryID = [self.xmlElementValue intValue];
}
else if ([elementName isEqualToString:@"destination"])
{
NSLog(@"DESTINATON %@", self.xmlElementValue);
[aTaxiQuery setDestination:self.xmlElementValue];
//aTaxiQuery.destination = self.xmlElementValue;
}
else if ([elementName isEqualToString:@"deptTime"])
{
[aTaxiQuery setDeptTime:self.xmlElementValue];
//aTaxiQuery.deptTime = self.xmlElementValue;
}
else if ([elementName isEqualToString:@"startingPt"])
{
[aTaxiQuery setStartingPt:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"boardingPass"])
{
[aTaxiQuery setBoardingPass:[self.xmlElementValue intValue]];
}
else if ([elementName isEqualToString:@"miscInfo"])
{
[aTaxiQuery setMiscInfo:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"seat1"])
{
[aTaxiQuery setSeat1:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"seat2"])
{
[aTaxiQuery setSeat2:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"seat3"])
{
[aTaxiQuery setSeat3:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"seat4"])
{
[aTaxiQuery setSeat4:self.xmlElementValue];
}
else if ([elementName isEqualToString:@"done"])
{
hTravelv12AppDelegate *appDelegate = (hTravelv12AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.queryList addObject:aTaxiQuery];
[aTaxiQuery release];
NSLog(@"QUERYLIST COUNT %i", [appDelegate.queryList count]);
if ([appDelegate.queryList count] == 1)
{
aTaxiQuery = [appDelegate.queryList objectAtIndex:0];
NSLog(@"QUERY %i >> %@, %@", aTaxiQuery.queryID, aTaxiQuery.destination, aTaxiQuery.startingPt);
}
else
{
aTaxiQuery = [appDelegate.queryList objectAtIndex:0];
NSLog(@"QUERY %i >> %@, %@", aTaxiQuery.queryID, aTaxiQuery.destination, aTaxiQuery.startingPt);
aTaxiQuery = [appDelegate.queryList objectAtIndex:1];
NSLog(@"QUERY %i >> %@, %@", aTaxiQuery.queryID, aTaxiQuery.destination, aTaxiQuery.startingPt);
}
}
//NSLog(@"aTAXIQUERY %@", aTaxiQuery.userName);
//[appDelegate.queryList addObject:aTaxiQuery];
//NSLog(@"QUERYLIST COUNT %i", [appDelegate.queryList count]);
}
Here is nslog result
Code:
2010-07-07 22:38:42.215 EC_Travel[9094:207] STARTED XML TAXI QUERY READER
2010-07-07 22:38:42.216 EC_Travel[9094:207] QUERYID 1
2010-07-07 22:38:42.217 EC_Travel[9094:207] DESTINATON Jurong Point
2010-07-07 22:38:42.218 EC_Travel[9094:207] QUERYLIST COUNT 1
2010-07-07 22:38:42.219 EC_Travel[9094:207] QUERY 1 >> Jurong Point, NGEE ANN POLY
2010-07-07 22:38:42.220 EC_Travel[9094:207] QUERYID 3
2010-07-07 22:38:42.221 EC_Travel[9094:207] DESTINATON boon lay
2010-07-07 22:38:42.222 EC_Travel[9094:207] QUERYLIST COUNT 2
2010-07-07 22:38:42.222 EC_Travel[9094:207] QUERY 3 >> boon lay, Ochard road
2010-07-07 22:38:42.224 EC_Travel[9094:207] QUERY 3 >> boon lay, Ochard road
2010-07-07 22:38:42.230 EC_Travel[9094:207] Database list
2010-07-07 22:38:42.232 EC_Travel[9094:207] Database list
I've a TaxiQuery object with the attributs queryID, destination etc.
I've a NSMutableArray ==>joinList at appDelegated. Initialized and declared.
I just don't understand why is the object added to the joinList being replaced and how should i add the TaxiQuery object to the joinList after i have set values to the attributes of TaxiQuery using the XML parse.
I am doing this for a school project and deadline is reaching.
I NEED HELP!!!!!!!!!!!!!!!!! ANNY KIND SOUL AROUND????? i'll always be refreshing this page ...hoping to find a solution
TKS IN ADVANCE!
-Perwyl