ios - Connect this NSSting with a String Variable -


all want change every time nsstring townlocation. because take data api , don't want create different api different location. know "+" put on link not correct , there not such think in objective c want make understand want.

  nsstring*townlocation;        nsdata* data = [nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://api.openweathermap.org/data/2.5/find?q="+townlocation+"&units=metric"]]; 

how must ? im sure understand i'm new @ objective c

thank you

you need basic nsstring documentation find method that, stringwithformat:.

nsstring *urlstring = [nsstring stringwithformat:@"http://api.openweathermap.org/data/2.5/find?q=%@&units=metric", townlocation]; nsdata *data = [nsdata datawithcontentsofurl:[nsurl urlwithstring:urlstring]]; 

if you're new @ objective-c, place find information search internet or ios developer library class in question (in case, nsstring) find myriad of resources @ disposal. doc check formatting string objects, linked in stringwithformat: section of ios developer library, find more info formatting strings.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -