{"id":1859,"date":"2009-01-15T12:20:46","date_gmt":"2009-01-15T16:20:46","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=1859"},"modified":"2014-04-15T20:31:51","modified_gmt":"2014-04-16T00:31:51","slug":"nsarrayfunctional","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2009\/01\/15\/nsarrayfunctional\/","title":{"rendered":"NSArray+Functional"},"content":{"rendered":"<p><a href=\"http:\/\/seriot.ch\/blog.php?article=20090109\">Nicolas Seriot<\/a> has written a <a href=\"http:\/\/seriot.ch\/software_cli.php#nsarray_functional\">category on NSArray<\/a> to add map, filter, and reduce functionality. You pass a selector and a variable number of arguments, and it performs the selector on each object in the array. <a href=\"http:\/\/mjtsai.com\/blog\/2008\/08\/28\/blocks-in-objective-c\/\">Blocks<\/a> are much nicer, of course, but they&rsquo;re not available yet in Objective-C. <a href=\"http:\/\/cocoadev.com\/index.pl?HigherOrderMessaging\">Higher order messaging<\/a> provides type-checking at compile time and supports more types of arguments, however the <code>va_arg<\/code> approach is simpler than HOM and works better with selectors that return <code>BOOL<\/code>.\r\n<\/p>","protected":false},"excerpt":{"rendered":"<p>Nicolas Seriot has written a category on NSArray to add map, filter, and reduce functionality. You pass a selector and a variable number of arguments, and it performs the selector on each object in the array. Blocks are much nicer, of course, but they&rsquo;re not available yet in Objective-C. Higher order messaging provides type-checking at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[168,69,859,54,71],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-blocks","tag-cocoa","tag-nsarray","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=1859"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1859\/revisions"}],"predecessor-version":[{"id":8708,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/1859\/revisions\/8708"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}