简体   繁体   English

Xcode 8结束符自动完成问题

[英]Xcode 8 End Closure Autocompletion Issue

Relatively new to IOS & Xcode from an Android background, I've found in a few tutorials pressing return on an ending closure and Xcode formatting it in a special way. 从Android背景开始,IOS和Xcode相对较新,我在一些教程中发现按结束符return并用特殊方式对其进行Xcode格式化。 In my case however, this does not always work. 但是,就我而言,这并不总是有效。

What happens before and after Enter is pressed for Me 为我按下Enter之前和之后会发生什么 在此处输入图片说明 在此处输入图片说明

What I've seen and would like it to do. 我所看到的并希望它做的。 在此处输入图片说明

Another Example as mentioned by this video(Start 13.06, End 13.16) https://youtu.be/v9JtVJUxX7k?t=13m6s 该视频提到的另一个示例(开始13.06,结束13.16) https://youtu.be/v9JtVJUxX7k?t=13m6s

Compared to other IDE's Xcode is very buggy currently so its hard to tell if this is just a bug or if I'm doing something wrong. 与其他IDE的Xcode相比,当前的bug很大,因此很难分辨这仅仅是一个bug还是我做错了什么。 Is anyone able to guide me on how I can go about acheiving this or why its happening? 有人能指导我如何实现这一目标或为什么会发生吗?

It appears for Xcode 8.1 autocomplete for trailing closures must be taken care of before any other placeholders. 对于Xcode 8.1,对于结尾的闭包,自动补全似乎必须在任何其他占位符之前进行处理。 Switching to Xcode 8.2 also solved this problem. 切换到Xcode 8.2也解决了这个问题。

For Example within the image, the trailing closure would have to be autocompleted before the request placeholder was edited to acheive the desired effect. 对于图像中的示例,在编辑请求占位符以实现所需效果之前,必须自动完成尾随闭包。 在此处输入图片说明

It's hard to tell for sure from your screenshot, but it looks like you aren't hitting the Return key while the completion handler placeholder is actually selected . 很难从屏幕截图中确定这一点,但是看起来好像在实际上选择了完成处理程序占位符的同时没有按下Return键。 You have to either tab to it, or click on the placeholder. 您必须选择它,或单击占位符。 In your color scheme I believe the placeholder background color will become more saturated and the text color inside the placeholder block will become dark instead of light. 在您的配色方案中,我相信占位符的背景色将变得更加饱和,并且占位符块内的文本颜色将变为深色而不是浅色。 In this selected placeholder state, pressing the Return key creates the trailing closure syntax you are hoping for. 在此选定的占位符状态下,按Return键将创建您希望的尾随闭包语法。

For what it's worth, I typed the exact same code you have in your example above in Xcode 8.2 beta 2, and when I select the placeholder block and press Return, I get the trailing closure syntax as expected 5 out of 5 times. 对于它的价值,我在Xcode 8.2 beta 2中键入了与您在上面的示例中完全相同的代码,并且当我选择占位符块并按Return键时,我得到了预期的尾随闭包语法(5次中有5次)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM