{"id":160314,"date":"2020-09-26T03:09:45","date_gmt":"2020-09-25T19:09:45","guid":{"rendered":"http:\/\/4563.org\/?p=160314"},"modified":"2020-09-26T03:09:45","modified_gmt":"2020-09-25T19:09:45","slug":"%e5%bc%80%e5%8f%91-mac-app-objective-c-%e4%b8%80%e4%b8%aa%e6%87%b5%e9%80%bc%e7%9a%84-nsdata-%e5%86%85%e5%ad%98%e6%b3%84%e9%9c%b2%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=160314","title":{"rendered":"\u5f00\u53d1 mac app objective c \u4e00\u4e2a\u61f5\u903c\u7684 NSData \u5185\u5b58\u6cc4\u9732\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5f00\u53d1 mac app objective c \u4e00\u4e2a\u61f5\u903c\u7684 NSData \u5185\u5b58\u6cc4\u9732\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : PUBG98k <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u5728 while \u5faa\u73af\u4e0b \u6267\u884c <br \/>NSData *data = [NSData dataWithBytes:buf length:size];<br \/>\u3002\u3002\u3002<br \/>\u4f1a\u5f15\u8d77 NSData \u5185\u5b58\u6cc4\u6f0f\uff0c<br \/>\u53ea\u80fd\u7b49\u5230\u5faa\u73af\u7ed3\u675f\u540e\uff0c\u624d\u91ca\u653e<br \/>\u6709\u5927\u4f6c\u9047\u5230\u8fc7\u8fd9\u4e2a\u95ee\u9898\u5417\uff1f\u77e5\u9053\u5982\u4f55\u89e3\u51b3\u5417\uff1f\u8c22\u8c22~<\/p>\n<p> void *buffer = (void*)malloc(pkt-&gt;data.frame.sz);<br \/>memcpy(buffer, pkt-&gt;data.frame.buf, pkt-&gt;data.frame.sz);<br \/> *data_p = [[NSData alloc] initWithBytesNoCopy:buffer length:pkt-&gt;data.frame.sz freeWhenDone:YES];<br \/>\/\/ packet.videoPacket.data_p = data_p;<br \/>\/\/ *free(buffer); \/\/ dataWithBytesNoCopy \u4e0d\u7528\u8fd9\u4e2a free      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3464091\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : PUBG98k <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u5934\u96fe\u6c34\u00b7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464092\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuan925 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 AutoReleasePool                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464093\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : godblessumilk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u4e0d\u662f\u6709\u91ce\u6307\u9488                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3464094\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shawndev <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             for \u5faa\u73af\u5927\u91cf\u7533\u8bf7\u5185\u5b58\u8981\u653e\u5728 autorelease pool \u91cc\uff0c\u53c2\u8003 https:\/\/github.com\/ibireme\/YYModel\/blob\/1230e605c1abdcd34bf0adb371d89783ff39a856\/Benchmark\/ModelBenchmark\/ViewController.m#L91                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u53d1 mac app object&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160314"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160314"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/160314\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}