1

我有一个正在迁移到 WatchOS 2.0 的 WatchKit 扩展项目,由于迁移后的某种原因,我收到一个编译器错误,指出 NSTextAttachment 是未知类型。我不确定这是否是 Xcode 7 的错误。它在 Xcode 6 和 WatchOS 1 中运行良好。只是所有引用 NSTextAttachment 的东西都给了我这个问题。WatchOS 2.0 或其他版本不可用吗?

以下代码:

NSTextAttachment *attachment = [[NSTextAttachment alloc] init];

导致错误:

Unknown type name 'NSTextAttachment'; did you mean 'NSTextAlignment'?
Use of undeclared identifier 'NSTextAttachment'

像 NSAttributedString 等其他所有东西都可以工作。

4

1 回答 1

0

您遇到的错误不是错误。实际上,WatchOS 不支持 NSTextAttachment,而且坏消息是,对于这个问题没有合适的替代解决方案。

于 2016-09-26T08:41:52.250 回答