{"id":3983,"date":"2014-03-30T06:57:01","date_gmt":"2014-03-30T06:57:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/add-date-to-mkannotation-title-property-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:57:01","modified_gmt":"2014-03-30T06:57:01","slug":"add-date-to-mkannotation-title-property-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/add-date-to-mkannotation-title-property-collection-of-common-programming-errors\/","title":{"rendered":"Add date to MKAnnotation title property-Collection of common programming errors"},"content":{"rendered":"<p>NSString&#8217;s <code>+stringWithFormat<\/code> returns an autoreleased object-since nothing else is taking ownership of it, your <code>title<\/code> is getting deallocated at the end of the run-loop cycle. You need to call <code>retain<\/code> on the new value of <code>title<\/code>, like this:<\/p>\n<pre><code>title = [[NSString stringWithFormat:@\"%@ %@\", t, [dateFormatter stringFromDate:today]] retain];\n<\/code><\/pre>\n<p>or, alternatively, set it to a newly-allocated instance (hence not an autoreleased one), like this:<\/p>\n<pre><code>title = [[NSString alloc] initWithFormat:@\"%@ %@\", t, [dateFormatter stringFromDate:today]];\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>NSString&#8217;s +stringWithFormat returns an autoreleased object-since nothing else is taking ownership of it, your title is getting deallocated at the end of the run-loop cycle. You need to call retain on the new value of title, like this: title = [[NSString stringWithFormat:@&#8221;%@ %@&#8221;, t, [dateFormatter stringFromDate:today]] retain]; or, alternatively, set it to a newly-allocated instance [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3983","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3983"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3983\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}