ios - Constructing NSStrings on the fly, mos effecient way -


i coordinates gps, need build small string looks :

      nsstring *location = @"40.7,-73.9"; 

my code right

       nsstring *latitude = [nsstring stringwithformat:@"%f", [locationfinder                                     singleton].location.coordinate.latitude];        nsstring *longtitude = [nsstring stringwithformat:@"%f", [locationfinder                                  singleton].location.coordinate.latitude];        // of course doesn;t work        nsstring *location = latitude, logtitude; 

now know can nsmutablestring , append, wanted aks ehether there effecient ay of doing process. coming .net , java hate obj c weirdness has.

the simplest answer best here, use +stringwithformat: actual multipart format string, instead of separately you're doing there:

coordinate *coord = [locationfinder singleton].location.coordinate; // or whatever type here nsstring *location = [nsstring stringwithformat:@"%f,%f", coord.latitude, coord.longitude]; 

but in general, question here great example of pointless micro-optimization.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -