xcode Swift 代码完成不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24076208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:01:10  来源:igfitidea点击:

Swift code completion isn't working

xcodeswiftcode-completion

提问by adeewu

I installed Xcode 6.0 betaand downloaded the iOS8library Documentation. but when i create a Swiftproject, try to typing code

我安装了Xcode 6.0 beta并下载了iOS8库文档。但是当我创建一个Swift项目时,尝试输入代码

func aa(){
    let format = NSDateFormatter()
    var pageData = format.
}

I find Xcode can't dot any property and function. Am I missing any step?

我发现 Xcode 无法添加任何属性和功能。我错过了任何步骤吗?

The problem is sloved, typing a whitespace can aid code completion

问题已解决,输入空格有助于代码补全

回答by Nicola? Philippe

It's append when you change the hardware type and you choose less than iphone5.

当您更改硬件类型并且您选择小于iphone5时,它会附加。

Choose Iphone 6 for example in the list at the right of the stop button and the code completion for 'format' will appear.

例如,在停止按钮右侧的列表中选择 Iphone 6,将出现“格式”的代码完成。

回答by jasonqu

I met the same problem and solve it by removing the non-ASCII char in comment (in my problem, it's a chinese char "年" automatically generated in comment by xcode).

我遇到了同样的问题并通过删除注释中的非 ASCII 字符来解决它(在我的问题中,它是 xcode 在注释中自动生成的中文字符“年”)。

btw. "typing a whitespace can aid code completion" doesn't work for me

顺便提一句。“输入空格可以帮助完成代码”对我不起作用

回答by noliv

It's a bug, your code works on my system (OS X 10.9). Note that when typing code, I sometimes see the code completion crash for two seconds and come back.

这是一个错误,您的代码适用于我的系统(OS X 10.9)。请注意,在键入代码时,我有时会看到代码完成崩溃两秒钟,然后又回来了。

When trying a first project named "swift", code completion crashed in a infinite loop… beta bugs… I just had to name it something else to test the language.

在尝试第一个名为“swift”的项目时,代码完成在无限循环中崩溃……beta 错误……我只需要给它命名其他东西来测试语言。

回答by Jay Versluis

You know, I've experienced something similar with Objective C projects in Xcode 6 Beta 1. It seems Apple have changed the default behaviour a bit:

你知道,我在 Xcode 6 Beta 1 中的 Objective C 项目中遇到过类似的事情。似乎 Apple 已经稍微改变了默认行为:

In Xcode 5.x code would always automatically complete as you type, but in this early beta try pressing ESCAPE - that will bring up the list you're looking for. Works for me. Some code auto completes as you type (both in Swift and Objective C), but at times only ESCAPE will bring up what we're looking for.

在 Xcode 5.x 中,代码总是会在您键入时自动完成,但在此早期测试版中,请尝试按 ESCAPE - 这将显示您要查找的列表。对我来说有效。某些代码会在您键入时自动完成(在 Swift 和 Objective C 中),但有时只有 ESCAPE 会显示我们正在寻找的内容。

I'm nor sure if this is expected behaviour or a bug (I'm guessing the latter).

我不确定这是预期的行为还是错误(我猜是后者)。

I must admit that your code works fine on my system without this trick. Just make sure you have code completion setup under Xcode - Preferences - Text Editing:

我必须承认,如果没有这个技巧,您的代码在我的系统上运行良好。只需确保您在 Xcode - Preferences - Text Editing 下设置了代码完成:

enter image description here

在此处输入图片说明