Tag: dictionary

MKPinAnnotationView downloaded image (@3x) not working for 6+

I am using map on my application, For pin drop, I want to set user’s image instead of default pin. I am downloading users image and setting it as per code I paste below. For different scale of devices I am using image name as per device scale like eg., 1 For non retina device […]

Weak-keyed dictionary in Objective-C

I’m wondering if it’s possible to have something similar to ActionScript 3’s Dictionary object with weak keys in Objective-C. I want to be able to ‘attach’ an instance of a class to other arbitrary instances. Example; MetaData *meta = [MetaData metaDataForObject:someObject]; meta.whatever = foo; And later: foo = [MetaData metaDataForObject:someObject].whatever; [foo doStuff]; The tricky part […]

Bidirectional Map in Cocoa

Cocoa provides NSDictionary, which essentially is an associative array. Is there a nice way to get bidirectional associativity? i.e. one way would have been if NSDictionary had a keyForObject: method which mirrored the behavior of objectForKey:. I don’t really care if NSDictionary is not the way to get this. I know NSDictionary does provide keysOfEntriesPassingTest: […]

How to show locations of friends on map near by 20 km from user current location in ios

I want to get locations of my friends near by me within 20km.App should track my current location and when i want to search for friends within 20km,It should show All my friends location on map. locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation […]

How to stop overwriting data

I am trying to save in my iOS app some data. I use the following code : NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@”yourPlist.plist”]; //inserting data NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; [dict setValue:categoryField.text forKey:@”Category”]; [dict setValue:nameField.text forKey:@”Name”]; [dict setValue:eventField.text forKey:@”Event”]; NSMutableArray *arr = [[NSMutableArray alloc] […]

How To Store JSON Parsed Data Into Plist Using Objective C?

I need to store JSON parsed data Into propertylist like below structure using objective C. My JSON Response From Server : {    “response”:{       “A”:{          “name”:”Arun”,          “age”:”20″,          “city”:”SFO”,  “subject”:2       },       “B”:{          “name”:”Benny”,          “age”:”20″,          “city”:”SFO”,  “subject”:1   },       “C”:{          “name”:”Nani”,          “age”:”30″,          “city”:”SFO”,  “subject”:0       }    },    “inprogressdata”:{    },    “dataspeed”:”112 milliseconds…” } I am trying like below storage method into propertylist. […]

Objective C + Reskit – How do I wrap my dictionary with a key to avoid formatting problems?

I’m trying to wrap my HTTP POST request with a key. In other words, I want to turn this: { “category_id”=>”1”, “food_name_token”=>”Pizza”, “id”=>”1” } into this: { “dish” => { “category_id”=>”1”, “food_name_token”=>”Pizza”, “id”=>”1″ } } I tried using the ‘rootKeyPath’ method in RestKit: serializationMapping.rootKeyPath = @”dish”; But that gave me this weirdly formatted string : […]

Is the Objective-C dictionary an ordered container?

as the title, when I insert element to a dictionary in objective-c (in order like: k1, k2, k3), is there any guarantee that when I enumerate it like: for ( k in dictionary ){ // output the k – value } it would show in the same order?

Object pointer value as key into dictionary

I want to use the object’s reference value as a key into a dictionary, as opposed to a copy of value of the object. So, I essentially want to store an object associated with a particular instance of another object in a dictionary and retrieve that value later. Is this possible? Is it completely against […]

Dynamically populate object properties with dictionary values

In Objective-C, I have a dictionary: firstName -> John lastName -> Smith age -> 34 and an object Person that has corresponding instance variables and properties (that handle memory management appropriately). I’d like to create a convenience initializer that takes a dictionary as an argument and populates all the object fields (via their properties for […]