{"id":3298,"date":"2011-04-15T14:32:37","date_gmt":"2011-04-15T19:32:37","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=3298"},"modified":"2011-04-15T14:32:39","modified_gmt":"2011-04-15T19:32:39","slug":"subclassing-nsinputstream","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2011\/04\/15\/subclassing-nsinputstream\/","title":{"rendered":"Subclassing NSInputStream"},"content":{"rendered":"<p><a href=\"http:\/\/bjhomer.blogspot.com\/2011\/04\/subclassing-nsinputstream.html\">BJ Homer<\/a> (via <a href=\"http:\/\/funwithobjc.tumblr.com\/post\/4626637919\/subclassing-nsinputstream\">Dave DeLong<\/a>):<\/p>\n<blockquote cite=\"http:\/\/bjhomer.blogspot.com\/2011\/04\/subclassing-nsinputstream.html\"><p><code>-[NSInputStream _scheduleInCFRunLoop:forMode:]<\/code> is the equivalent of <code>CFReadStreamScheduleWithRunLoop<\/code> for your stream. Do whatever you need to do so that you can give proper <code>kCFStreamEventHasBytesAvailable<\/code> notifications (and any other notifications requested) at the proper time. That may involve scheduling a timer on the run loop, or if your subclass is just wrapping a vanilla NSInputStream, simply scheduling <i>that<\/i> stream on the run loop. Implement this method as if you were implementing <code>CFReadStreamScheduleWithRunLoop<\/code> for your stream.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>BJ Homer (via Dave DeLong): -[NSInputStream _scheduleInCFRunLoop:forMode:] is the equivalent of CFReadStreamScheduleWithRunLoop for your stream. Do whatever you need to do so that you can give proper kCFStreamEventHasBytesAvailable notifications (and any other notifications requested) at the proper time. That may involve scheduling a timer on the run loop, or if your subclass is just wrapping [&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":[],"class_list":["post-3298","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/3298","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=3298"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/3298\/revisions"}],"predecessor-version":[{"id":3299,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/3298\/revisions\/3299"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=3298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=3298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=3298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}