{"id":10974,"date":"2015-04-06T12:59:44","date_gmt":"2015-04-06T16:59:44","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10974"},"modified":"2015-04-06T12:59:44","modified_gmt":"2015-04-06T16:59:44","slug":"mustoverride","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/04\/06\/mustoverride\/","title":{"rendered":"MustOverride"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/nicklockwood\/MustOverride\">Nick Lockwood<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/nicklockwood\/MustOverride\">\n<p>MustOverride provides a macro that you can use to ensure that a method of an abstract base class <em>must<\/em> be overriden by its subclasses.<\/p>\n<p>Apple does not currently provide a way to flag this at compile time, and the standard approach of raising an exception in the base class&rsquo;s implementation has two disadvantages: 1) it means that the method will only crash when it is called, which might only happen under difficult-to-reproduce conditions, and 2) you cannot provide a base implementation and require that the subclass calls super.<\/p>\n<p>MustOverride uses some runtime magic to scan the class list at load time, and will crash <em>immediately<\/em> when the app is launched if the method is not implemented, even if it is never called.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Nick Lockwood: MustOverride provides a macro that you can use to ensure that a method of an abstract base class must be overriden by its subclasses. Apple does not currently provide a way to flag this at compile time, and the standard approach of raising an exception in the base class&rsquo;s implementation has two disadvantages: [&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":[31,30,941,54,74,71],"class_list":["post-10974","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-mac","tag-macros","tag-objective-c","tag-opensource","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10974","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=10974"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10974\/revisions"}],"predecessor-version":[{"id":10975,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10974\/revisions\/10975"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}