{"id":7740,"date":"2013-08-28T13:21:58","date_gmt":"2013-08-28T18:21:58","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=7740"},"modified":"2014-04-15T20:36:10","modified_gmt":"2014-04-16T00:36:10","slug":"cocoa-nserror-conventions","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/08\/28\/cocoa-nserror-conventions\/","title":{"rendered":"Cocoa NSError Conventions"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/AFNetworking\/AFNetworking\/pull\/1260#issuecomment-23361266\">C&eacute;dric Luthi<\/a>:<\/p>\r\n<blockquote cite=\"https:\/\/github.com\/AFNetworking\/AFNetworking\/pull\/1260#issuecomment-23361266\"><p>Follow Cocoa conventions for methods without parameters returning errors, i.e. <code>xxxAndReturnError:(NSError **)error<\/code> instead of just <code>xxx:(NSError **)error<\/code>.<\/p><\/blockquote>\r\n<p>The Cocoa APIs are inconsistent and use both patterns. Sometimes the <code>error<\/code> parameter is an <code>NSError<\/code>, other times an <code>NSDictionary<\/code>.<\/p>\r\n<p>I dislike the ambiguity of <code>-save:<\/code> and the verbosity of <code>-saveAndReturnError:<\/code> (which, incidentally, <em>returns<\/em> a <code>BOOL<\/code>), so in my own code I&rsquo;ve been using names like <code>-saveError:<\/code> (which has its own problems&#8230;).<\/p>","protected":false},"excerpt":{"rendered":"<p>C&eacute;dric Luthi: Follow Cocoa conventions for methods without parameters returning errors, i.e. xxxAndReturnError:(NSError **)error instead of just xxx:(NSError **)error. The Cocoa APIs are inconsistent and use both patterns. Sometimes the error parameter is an NSError, other times an NSDictionary. I dislike the ambiguity of -save: and the verbosity of -saveAndReturnError: (which, incidentally, returns a BOOL), [&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":[69,860,857,54,71],"class_list":["post-7740","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-nsdictionary","tag-nserror","tag-objective-c","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7740","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=7740"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7740\/revisions"}],"predecessor-version":[{"id":8712,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/7740\/revisions\/8712"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=7740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=7740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=7740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}