Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: Data Merging
View Single Post
Old 04-06-2009, 12:13 PM   #5 (permalink)
BNZ
New Member
 
Join Date: Apr 2009
Posts: 10
Default

Of course

I have a basic if statement to see if the current location has been found, if it has it uses the same code as below with a bit more padding to calculate a distance, if current location has not been found the arrary of locations is updated with a new key called distance with a value of Location Not Found.

Basically it reads the object from the current array index into a dictionary (not required here as we allready know the location has not been found), uses the location information about the object that it pulled from the array (once again not shown here), creates a new string - distancestring, adds a new key to the array (distance) and adds the distancestring as the value to the new key.


Code:
	
for (i = 0; i < count; i++) {
//NSDictionary *itemAtIndex = (NSDictionary *)[tempArray objectAtIndex:i];
NSString *distanceString;
distanceString = @"Location Not Found";
NSArray *newObjectKeys = [itemAtIndex allKeys];
newObjectKeys = [newObjectKeys arrayByAddingObject:@"distance"];
NSArray *newObjectArray = [itemAtIndex allValues];
newObjectArray = [newObjectArray arrayByAddingObject:distanceString];
NSDictionary *newObjectDictionary = [NSDictionary dictionaryWithObjects:newObjectArray forKeys:newObjectKeys];
[tempArray replaceObjectAtIndex:i withObject:newObjectDictionary];
}
BNZ is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,754
Threads: 38,524
Posts: 169,208
Top Poster: smasher (2,543)
Welcome to our newest member, labouhassan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:16 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.