ios - MKMapitem's Placemark.name is nil when creating MKMapItem from MKPlacemark -


mkplacemark *placemark1 = [[mkplacemark alloc] initwithplacemark:mapitem1.placemark];  mkmapitem *item = [[mkmapitem alloc] initwithplacemark:placemark1];  nslog(@"placemark1.name - %@", placemark1.name) 

placemark1.name - starbucks

nslog(@"mapitem1's placemark.name - %@", mapitem1.placemark.name)  

mapitem1's placemark.name - starbucks

nslog(@"item's placemark.name - %@", item.placemark.name)  

item's placemark.name - nil

mapitem1 has proper value. mapitem1.placemark.name @"startbucks".

when implement above, item.placemark.name nil. placemark1.name @"sartbucks".

when made mkmapitem mkplacemark, place mark.name in mkmapitem nil.

i don't know why these result has returned.

i think same value of original placemark has returned.

i'm assuming mapitem1 of type mkmapitem? if true, don't need initialize new mkplacemark object(*placemark1), nor need store placemark1 in new mkmapitem object(*item).

since you're calling placemark on mapitem1 in code (mapitem1.placemark) think i'm right assuming of type mkmapitem.

to sum don't need these lines of code @ all:

mkplacemark *placemark1 = [[mkplacemark alloc] initwithplacemark:mapitem1.placemark];  mkmapitem *item = [[mkmapitem alloc] initwithplacemark:placemark1]; 

your mkmapitem *mapitem1 work is. make sense? you're kind of reinventing wheel here. use mapitem1.placemark wherever need use it. i've been working on project uses mapkit, if have questions i'd happy answer them.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -