Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2010, 09:43 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 12
perwyl is on a distinguished road
Default PROBLEM adding XML DATA to ARRAY

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
perwyl is offline   Reply With Quote
Reply

Bookmarks

Tags
array, iphone, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 336
9 members and 327 guests
bignoggins, Chickenrig, firecall, givensur, iNet, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:33 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0