{"id":4557,"date":"2014-03-30T13:32:01","date_gmt":"2014-03-30T13:32:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-nsoject-from-nsdictionary-into-nsstring-collection-of-common-programming-errors\/"},"modified":"2014-03-30T13:32:01","modified_gmt":"2014-03-30T13:32:01","slug":"how-to-nsoject-from-nsdictionary-into-nsstring-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-nsoject-from-nsdictionary-into-nsstring-collection-of-common-programming-errors\/","title":{"rendered":"How to NSOject from NSDictionary into NSString?-Collection of common programming errors"},"content":{"rendered":"<p>Max has the correct casting syntax, but to be safe you&#8217;ll want to do some kind of instance check at runtime, since it&#8217;s not possible at compile-time in Objective-C to ensure that the type of an object in an array or dictionary is what you&#8217;re expecting:<\/p>\n<pre><code>NSObject *obj = [item objectForKey:@\"link\"];\nif ([obj isKindOfClass:[NSString class]]) {\n   NSString *stringValue = (NSString *)obj;\n   \/\/ Do something with the NSString\n} else {\n   \/\/ You can alternatively raise an NSException here.\n   NSLog(@\"Serious error, we expected %@ to be an NSString!\", obj);\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Max has the correct casting syntax, but to be safe you&#8217;ll want to do some kind of instance check at runtime, since it&#8217;s not possible at compile-time in Objective-C to ensure that the type of an object in an array or dictionary is what you&#8217;re expecting: NSObject *obj = [item objectForKey:@&#8221;link&#8221;]; if ([obj isKindOfClass:[NSString class]]) [&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-4557","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4557","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=4557"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4557\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}