{"id":47917,"date":"2025-06-02T18:47:03","date_gmt":"2025-06-02T22:47:03","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=47917"},"modified":"2025-06-02T18:49:59","modified_gmt":"2025-06-02T22:49:59","slug":"separate-expresions-for-alloc-and-init","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/06\/02\/separate-expresions-for-alloc-and-init\/","title":{"rendered":"Separate Expressions for +alloc and -init"},"content":{"rendered":"<p><a href=\"https:\/\/blog.ronaldoussoren.net\/2025\/06\/01\/fun-with-reference-counts.html\">Ronald Oussoren<\/a>:<\/p>\n<blockquote cite=\"https:\/\/blog.ronaldoussoren.net\/2025\/06\/01\/fun-with-reference-counts.html\">\n<p>The following code will crash hard when compiled using ARC:<\/p>\n\n<pre>#import &lt;Foundation\/Foundation.h&gt;\n\nint main(void)\n{\n     NSOutputStream* stream;\n\n      stream = [NSOutputStream alloc];\n      stream = [stream initToMemory];\n\n      NSLog(@\"%@\", stream);\n}\n<\/pre>\n\n<p>This is split calls to <code>alloc<\/code> and <code>initToMemory<\/code> are effectively what happens when using <code>NSOutputStream.alloc().initToMemory()<\/code> in Python.<\/p>\n<p>[&#8230;]<\/p>\n<p>This appears to be a genuine bug in macOS, filed as FB17759654.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ronald Oussoren: The following code will crash hard when compiled using ARC: #import &lt;Foundation\/Foundation.h&gt; int main(void) { NSOutputStream* stream; stream = [NSOutputStream alloc]; stream = [stream initToMemory]; NSLog(@\"%@\", stream); } This is split calls to alloc and initToMemory are effectively what happens when using NSOutputStream.alloc().initToMemory() in Python. [&#8230;] This appears to be a genuine bug [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-06-02T22:47:05Z","apple_news_api_id":"65562385-c6c0-48ed-8e7e-4f7b01eed197","apple_news_api_modified_at":"2025-06-02T22:47:16Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AZVYjhcbASO2Ofk97Ae7Rlw","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":[55,131,69,30,2598,571,54,71,635],"class_list":["post-47917","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-arc","tag-bug","tag-cocoa","tag-mac","tag-macos-15-sequoia","tag-memory-management","tag-objective-c","tag-programming","tag-pyobjc"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47917","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=47917"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47917\/revisions"}],"predecessor-version":[{"id":47919,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47917\/revisions\/47919"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=47917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=47917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=47917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}