<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1474204230469_5429"><span>Hi all,</span></div><div id="yui_3_16_0_1_1474204230469_5429"><span><br></span></div><div id="yui_3_16_0_1_1474204230469_5429"><span id="yui_3_16_0_1_1474204230469_5801">Another question.&nbsp;</span>I used to use this snippet to read keyboard input from XCode's Playground. And it used to work very well. Today, I just updated my XCode to v.8 and Swift v.3. After a little bit modification here and there due to Swift 3 incompatibility, I got this code compiled without error. But it doesn't work. No keyboard input is taken. It just stucks.</div><div id="yui_3_16_0_1_1474204230469_5837"><br id="yui_3_16_0_1_1474204230469_5838"></div><div dir="ltr" id="yui_3_16_0_1_1474204230469_5839">Here's the code:</div><div dir="ltr" id="yui_3_16_0_1_1474204230469_5839"><br></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6149"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6150">import</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6151"> Foundation</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_1_1474204230469_6152"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6153"></span><br id="yui_3_16_0_1_1474204230469_6154"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6155"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6156">func</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6157"> input() -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6158">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6159"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6160"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6161">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6162">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6163"> keyboard&nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6164">FileHandle</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6165">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6166">standardInput</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6167"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6168">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6169">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6170"> inputData = keyboard.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6171">availableData</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6172"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6173">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6174">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6175"> encoding&nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6176">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6177">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6178">Encoding</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6179">(rawValue: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6180">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6181">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6182">Encoding</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6183">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6184">utf8</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6185">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6186">rawValue</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6187">)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6188"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6189">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6190">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6191"> strData &nbsp; = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6192">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6193">(data: inputData, encoding: encoding)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6194"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6195">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6196">return</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6197"> strData! </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6198">as</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6199"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6200">String</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6201"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6202">}</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_1_1474204230469_6203"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6204"></span><br id="yui_3_16_0_1_1474204230469_6205"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6206"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6207">func</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6208"> write(</span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6209">_</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6210"> txt: </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6211">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6212">) {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6213"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6214">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6215">print</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6216">(txt, terminator: </span><span style="font-variant-ligatures: no-common-ligatures; color: #e82300" id="yui_3_16_0_1_1474204230469_6217">""</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6218">)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6219"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6220">}</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_1_1474204230469_6221"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6222"></span><br id="yui_3_16_0_1_1474204230469_6223"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6469"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6470">func</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6471"> read() -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6472">String</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6473"> {</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_1_1474204230469_6474"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6475">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6476">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6477"> c = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c35900" id="yui_3_16_0_1_1474204230469_6478">CharacterSet</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6479">.</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6480">whitespacesAndNewlines</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);" id="yui_3_16_0_1_1474204230469_6481"><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6482">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6483">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6484"> </span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6485">input</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6486">().</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6487">trimmingCharacters</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6488">(in: c)</span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_1_1474204230469_6221">}<br></div><div dir="ltr" id="yui_3_16_0_1_1474204230469_6491"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6492"><br id="yui_3_16_0_1_1474204230469_6493"></span></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" id="yui_3_16_0_1_1474204230469_6224"><span style="color: rgb(207, 135, 36);" id="yui_3_16_0_1_1474204230469_6418">/* main program */</span><br></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" id="yui_3_16_0_1_1474204230469_6283"><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6284"></span><br id="yui_3_16_0_1_1474204230469_6285"></div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(232, 35, 0);" id="yui_3_16_0_1_1474204230469_6286"><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6287">write</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6288">(</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6289">"Enter your name: "</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" id="yui_3_16_0_1_1474204230469_6290">)</span></div><div dir="ltr" id="yui_3_16_0_1_1474204230469_5839">





























</div><div style="margin-top: 0px; margin-bottom: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" dir="ltr" id="yui_3_16_0_1_1474204230469_6291"><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" id="yui_3_16_0_1_1474204230469_6292">let</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6293"> s = </span><span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" id="yui_3_16_0_1_1474204230469_6294">read</span><span style="font-variant-ligatures: no-common-ligatures" id="yui_3_16_0_1_1474204230469_6295">()</span></div><div></div><div id="yui_3_16_0_1_1474204230469_5427">&nbsp;</div><div class="signature" id="yui_3_16_0_1_1474204230469_5807"><div id="yui_3_16_0_1_1474204230469_5854"><div id="yui_3_16_0_1_1474204230469_6371">So, does anyone know how to make it works (again)? Thank you.</div><div id="yui_3_16_0_1_1474204230469_6372"><br id="yui_3_16_0_1_1474204230469_6373"></div><div dir="ltr" id="yui_3_16_0_1_1474204230469_6374">Regards,</div></div><div id="yui_3_16_0_1_1474204230469_5854"><br></div>–Mr Bee<div id="yui_3_16_0_1_1474204230469_5853"><br></div></div></div></body></html>