问题标签 [swift4.1]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
369 浏览

swift - 在 swift 4.1 中使用 nil 合并进行隐式展开时出现意外的“some()”

我在运行此代码时遇到了来自运行 swift 4.1 的 xcode 9.3 的奇怪响应:

响应是some(2)2(强制展开)(检查下图)。

这是some从哪里来的?(请解释或提供参考以了解更多信息some

在此处输入图像描述

0 投票
1 回答
31 浏览

swift4.1 - 访问类内的私有数组时出错

当我尝试访问类 (MyArray) 中的私有数组 (arr) 时,我收到一条错误消息。我想要实现的是创建一个用于反转数组内容的闭包,并且可以使用实例变量从类外部调用这个闭包。我无法理解这个错误。有人可以帮忙吗!

0 投票
1 回答
139 浏览

swift - 我无法使用 Xcode 9.2 导入 swift 4 模块

我有 Xcode 9.2,我想我自动拥有 Swift 4.1。所以我尝试导入一些模块,例如:

但它给了我一个错误,说它无法识别这些模块。如何在我的 Xcode 上访问 Swift 4.1?

在此处输入图像描述

0 投票
1 回答
1837 浏览

ios - 类型“NSAttributedStringKey”(又名“NSString”)没有成员“foregroundColor”

以下是上述问题的代码行。此问题发生在Swift 4.1.

0 投票
1 回答
592 浏览

swift - 二元运算符“===”不能应用于“Self.Element”和“AnyObject”类型的操作数

我收到以下错误:Binary operator '===' cannot be applied to type of 'Self.Element' and 'AnyObject' on the line: return contains { $0 === object }

有没有办法转换object为 的类型Iterator.Element?这条线是否where Iterator.Element: AnyObject意味着Iterator.Element必须可以表示为AnyObject

感谢您对此事的任何帮助。

0 投票
2 回答
4623 浏览

ios - SF Pro Text Medium font is not found in swift code

I'm using xCode 9.3.1 & Swift 4.1.

I'm trying to use SF Pro Text Medium font in my app code programatically. But this font is not found in the source code in swift file and app crashes.

Here is the code: NSAttributedStringKey.font: UIFont(name: ".SFProText-Medium", size: 24.0)!

At run time it throws following error: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Any other standard font work.

This font is available in the storyboard and I've used it successfully.

Why doesn't it work programatically? Do I've to add it in the xCode (plist etc) to make it work?

0 投票
1 回答
4423 浏览

swift - 结构是文件私有的,不能从 swift 4.1 中的默认参数值引用

我使用这样的默认值结构。

我有一个方法可以将这些结构值作为默认参数传递。但在 swift4 中它不起作用。

请在此处查看总代码。

有什么办法解决这个问题?

谢谢...

0 投票
1 回答
1384 浏览

ios - 如何使用背景图像删除 > iOS 10 和 Swift 4 中的 Tab Bar 顶部边框(阴影)?

我一直在尝试从 Swift 4 for > iOS 10 的选项卡栏中删除顶部边框(阴影)线。我也在使用自定义背景图像。我在寻找解决方案后刚刚放弃,因为它们都不起作用。

最接近的解决方案是这篇文章

如果没有背景或 < iOS 10,则到处给出的解决方案都有效。对于 iOS > 10 并使用自定义背景图像,任何解决方案都不起作用。

我什至尝试使用透明阴影图像,但它需要将 cliptobounds 设置为 true,这不会显示自定义背景图像。

所以在所有这些解决方案结束时,我被卡住了。找不到任何可行的解决方案。

我在 AppDelegate 中设置这些自定义值,以便它适用于所有选项卡栏。

0 投票
1 回答
2676 浏览

ios - 通过访问 AppDelegate 中的 Tab Bar Items 更改 Tab Bar Item Image inset

我想在我的标签栏中对齐标签栏项目图像。我知道我可以在 IB 中做到这一点,而且我做到了。但是我想以编程方式进行。我正在尝试在 AppDelegate 中执行此操作。以下是我的代码,它不起作用。谁能指出我做错了什么?

0 投票
1 回答
87 浏览

api - 蒸汽构建失败

Iam 目前是 Vapor Swift 服务器端的新手,最初我有两个查询

1)问题

蒸汽构建失败

错误:

构建失败。

2) 问题

运行时我得到 localhost:8080/Hello 这个 url 在 Safari 浏览器中工作正常

当谈到 Ios 应用程序时,我调用了我得到的 URl GET 方法

错误

获取 http:0.0.0.0:8080/Hello,HTTP 状态代码 503 时出错

如何在 Java、Javascript 等任何语言之外测试 Vapor Api