<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Sun, 10 May 2026 04:35:50 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Arbi - 2017-09-08 06:46:23</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>Currently we are using object mapper for coding decoding json and mapping return data. Apple did us a big favor by introducing the decodable and encodable protocol.I love how detailed you have gotten with it . I really appreciate and I will use it once I upgrade to swift 4.0 and Xcode 9.</description><guid isPermaLink="true">63c6cd5ffc7acad4c4b72e541223a403</guid><pubDate>Fri, 08 Sep 2017 06:46:23 GMT</pubDate></item><item><title>Maxim - 2017-09-01 15:27:14</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>Sorry it's me again, just browsed through the code on github and saw that you turn FixedWidthInteger to bigEndian. Does CFConvertFloatHostToSwapped convert floats to big endian as well?</description><guid isPermaLink="true">1d80b91f6776298e81acefff07ea383c</guid><pubDate>Fri, 01 Sep 2017 15:27:14 GMT</pubDate></item><item><title>Maxim - 2017-09-01 15:19:13</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>Hi Mike, thank you very much for the great article. Could you elaborate on CFConvertFloatHostToSwapped. Why exactly do you need it? I though it would imply the endianness of the machine but, there is no sign of changing ints to a particular endian in the example.</description><guid isPermaLink="true">d425a1788b378c2cc139eec71f10aca2</guid><pubDate>Fri, 01 Sep 2017 15:19:13 GMT</pubDate></item><item><title>Colin - 2017-08-31 05:01:03</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>Huh. I actually need a binary coder. Thx!
&lt;br /&gt;
&lt;br /&gt;I've got a vector drawing app, and to store raw stroke point data needs to be fast. I'm currently using messagepack, which is alright. But faster would always be better for this!
&lt;br /&gt;
&lt;br /&gt;Any data on performance of your implementation? Looks like it could be pretty optimal, this approach...</description><guid isPermaLink="true">f5fc3486357c5f0eb34b2a27c259e08f</guid><pubDate>Thu, 31 Aug 2017 05:01:03 GMT</pubDate></item><item><title>mikeash - 2017-08-01 13:22:34</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>&lt;b&gt;David Waite:&lt;/b&gt; I give you minus two points for missing the part of the article where I mention that, but plus five points for figuring out the problem and a solution, so good job overall!</description><guid isPermaLink="true">7a62e5577697e7aba515ba5f0d0218d4</guid><pubDate>Tue, 01 Aug 2017 13:22:34 GMT</pubDate></item><item><title>David Waite - 2017-08-01 03:33:54</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>...aaaaand never mind, thats exactly what you did. I guess I may be publicly humiliated at your sole discretion now.</description><guid isPermaLink="true">4ab8c7dd02512350ac8169a597a83ce9</guid><pubDate>Tue, 01 Aug 2017 03:33:54 GMT</pubDate></item><item><title>David Waite - 2017-08-01 03:25:01</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>Similar to how you are swapping host bytes for floating point and integer numbers to big-endian/network byte order, shouldn't you always encode Int as 64 bits, and error on decode if the platform cannot fit the number?</description><guid isPermaLink="true">6b6f7c30e30bbc391d79ef3e455ea4a9</guid><pubDate>Tue, 01 Aug 2017 03:25:01 GMT</pubDate></item><item><title>mikeash - 2017-07-31 18:18:32</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>&lt;b&gt;Alan W:&lt;/b&gt; Thanks, I fixed that too. Who would have thought that the one piece of code in this post that I just wrote for the article and didn't test would be full of errors. If only there was some sort of lesson in here for me.</description><guid isPermaLink="true">a0fe639a21138c4bdf206e8a96a08e75</guid><pubDate>Mon, 31 Jul 2017 18:18:32 GMT</pubDate></item><item><title>Alan W - 2017-07-30 18:18:42</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>I think that 
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code&gt;let roundtrippedCompany = try BinaryDecoder.decode(T.self, data: data)&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;should be
&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;code&gt;let roundtrippedCompany = try BinaryDecoder.decode(Company.self, data: data)&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;It made a lot more sense when I saw that in the unit test. =)</description><guid isPermaLink="true">a7e8c0bc7224c52b393d7588fc755152</guid><pubDate>Sun, 30 Jul 2017 18:18:42 GMT</pubDate></item><item><title>mikeash - 2017-07-29 18:27:19</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>&lt;b&gt;Svetoslav:&lt;/b&gt; Yes indeed. I fixed it. Thanks!</description><guid isPermaLink="true">1b065230a0c00c056dd83ce63167c9fd</guid><pubDate>Sat, 29 Jul 2017 18:27:19 GMT</pubDate></item><item><title>Svetoslav - 2017-07-29 17:34:18</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2017-07-28-a-binary-coder-for-swift.html#comments</link><description>The line
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let data = try BinaryEncoder.encode(original)
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;should be
&lt;br /&gt;&lt;code&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let data = try BinaryEncoder.encode(company)
&lt;br /&gt;&lt;/code&gt;
&lt;br /&gt;</description><guid isPermaLink="true">14425aaa35d505a99fe4979fa4476911</guid><pubDate>Sat, 29 Jul 2017 17:34:18 GMT</pubDate></item></channel></rss>
