- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
SENARIO
我正在开发一个项目,将 Swift 3 合并到 Objective-C 项目中。该项目正在使用 CoreData,在我的 Objective-C AppDelegate
中,我声明了“EntityName”的类型,并尝试在我的 Swift 3 类中进行分配,但收到构建错误“无法分配 ' 的类型” EntityName' 来输入“EntityName!”。
代码
AppDelegate.h
// Declaration
@property (strong, nonatomic) EntityName * entity;
Swift 类
// Array Property
var entityList = [EntityName]()
...
// Assignment
let appDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.entity = self.entityList[indexPath.row] // throws error
<小时/>
错误
can not assign type of 'EntityName' to type 'EntityName!'
<小时/>
我尝试过的
1)
appDelegate.entity = self.entityList[indexPath.row] as EntityName! // throws error
错误
can not assign type of 'EntityName!' to type 'EntityName!'
2)
appDelegate.entity = self.entityList[indexPath.row] as EntityName? // throws error
错误
can not assign type of 'EntityName?' to type 'EntityName!'
<小时/>
问题
我该如何纠正这个问题并继续我的一天?
最佳答案
经过一番尝试和错误后,我找到了解决此问题的方法。就我而言,我必须遵循以下步骤:
1)导航到并选择 CoreData 模型...
AppName.xcdatamodeld
2) 在右侧,查看文件检查器...
3)在代码生成部分,选择 Objective-C 作为语言...
<小时/>我的 .xcdatamodeld
文件代码生成设置为 Swift。我相信这句老话“让 Swift 符合 Objective-C 比 Objective-C 符合 Swift 更容易”在这里是正确的。
关于ios - Objective-C + Swift with CoreData - 无法将 'EntityName' 的值类型分配给类型 'EntityName!',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41109840/
SENARIO 我正在开发一个项目,将 Swift 3 合并到 Objective-C 项目中。该项目正在使用 CoreData,在我的 Objective-C AppDelegate 中,我声明了“
我使用简单的值,但我从未使用过值。(实体名称)。所以我对此感到困惑。我认为值用于获取当前值,但我在这里不明白。 public Tax Tax { get
我们在野外遇到过这种崩溃,当然我们不能在本地进行 repo 。它似乎只发生在 ios 7 上。它是一个 NSInternalInconsistencyException 的事实告诉我们这是一个内部 N
我是 coreData 编程的新手,我按照教程一步一步进行,当我收到此错误并陷入困境时,不知道这意味着什么 entityName.state must have a defined type
我正在尝试将 xml 文档加载到 C# 中的对象 XPathDocument 中。我的 xml 文档包括这一行:trés dégagée + rade当解析器到达那里时,它给了我这个错误:“解析 En
当使用“instruments”跟踪未引用的分配时,我看到了数千个 CDSnapshot[entityName]_ 实例。 这是什么?我认为它与 CoreData 相关? 最佳答案 是的,这与核心数据
我已经开始学习 Hibernate 并且有一个基本问题。 org.hibernate.Session 中的save(String entityName, Object object) 和save(Ob
以下查询有效: @Query("select o from Employee o where o.tenant.id = ?#{context.tenantId}") @Query("select o
在 Microsoft 的 Dynamics CRM 2011 实践实验室之后,我尝试将自定义 View 添加到响应特定属性的“onchange”的表单。这是我添加自定义 View 的函数: func
我发现我的代码中存在"&",这就是显示错误的原因 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dsExport.Tables[0].R
当我设计QueryExpression 时,我总是使用以下硬编码语法。 QueryExpression expression = new QueryExpression { EntityName
我知道这可能看起来重复,但我尝试了几个答案,但所有这些都不起作用。 我正在尝试使用核心数据来存储已完成的级别,但我在保存数据时遇到了一些麻烦。当一个级别完成时,将调用以下行。 let appD
Xcode 8 在您的 NSManagedObject 子类上提供了一个自动生成的 extension,看起来像这样: // Animal+CoreDataProperties.swift impo
我正在为我的 winforms 应用程序使用自定义控制代码来创建自定义彩色进度条。我可以构建它,它工作正常,但每次我尝试使用设计器时,它都会崩溃。 “解析 EntityName 时出错” 如果我从工具
我在 Swift 2.1 和 Xcode 7.2 中使用核心数据此代码给我一个无法找到实体名称的错误。这因为 [Company] 不起作用。我有一个具有此名称的实体。 let fetchReq
我从下面的代码块中得到以下异常。 解析 EntityName 时出错。 Line1,位置 844。 我试图将从表中检索到的数据集解析为数据集。 public DataSet BindMasterDat
我有一个函数,我将一个字符串作为参数传递给名为 filterXML 的参数,其中一个属性中包含“&”。 我知道 XML 不会识别它,它会给我一个错误。这是我的代码: public XmlDocume
我正在尝试对我的实体之一的属性使用延迟加载 属性映射是这样的: 但是,当我尝试保存此实体的实例(使用 Linq)时,它会抛出 DatabaseQueryException 并带有以下内部异常: NH
我首先使用实体框架 6 代码。我有三个这样的实体: public class Doctor { public string DoctorID { get; set; } publi
我升级了一个从 ef4 开始的旧项目,但现在我将它迁移到了 ef5。 这是旧代码: protected void SaveEntity(T entity) { using (DocsM
我是一名优秀的程序员,十分优秀!