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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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
 

» Advertisements
» Stats
Members: 158,627
Threads: 89,143
Posts: 380,334
Top Poster: BrianSlick (7,110)
Welcome to our newest member, Hirley2324
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.