Adding an int or float to an Array or Dictionary
Posted by eric | Filed under Lab Work, Personal, Programming
omg, i can’t believe how strict Objective C can be. While working with MKMapView on an iPhone app i am currently writing, i was trying to pass the lattitude and longitude to a custom class. My code looked like:
NSDictionary *locationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:49.277778,@"lat",-123.108889,@"long",nil];
alas, one must do this:
NSDictionary *locationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:49.277778],@"lat",[NSNumber numberWithFloat:-123.108889],@"long",nil];
i think i need to start a post of the little things that drive me mad in this crazy language. By far , concatenating a string is the winner.
Tags: iPhone, Objective C