SortInPlace 表达式太复杂 - Xcode 更新
SortInPlace expression was too complex - Xcode update
更新到 Xcode 7 后,我的 iOS 应用程序停止编译(由于几个 "changes"),但是我想出了一些我不知道该怎么做的东西让任何更简单。我需要根据以下三个条件对数组进行排序:
appDelegate.all_breeds!.sortInPlace { (a, b) -> Bool in
(a.breedNameES == nil) ||
(b.breedNameES == nil) ||
(a.breedNameES! < b.breedNameES!)
}
基本上我需要查看西班牙语中的品种 A 是否为零,或者西班牙语中的品种 B 是否为零,否则我需要比较两个品种,并按字母顺序对它们进行排序。
在我更新到 xCode 7 之前,这一直没有问题,现在我得到的错误是
Expression was too complex to be solved in reasonable time;
consider breaking up the expression into distinct subexpressions.
问题是我不能把它分解成子表达式,这是我能想到的最基本的。
有解决这个问题的想法吗?
问题的一部分显然是 Breed 是我的 AppDelegate 中的一个结构,它迫使编译器遍历所有结构以找到它。这使得表达式需要更多时间来编译。
错误信息
Expression was too complex to be solved in reasonable time
可能有多种原因。一是编译器无法推断出
自动从上下文中提取表达式类型。在那种情况下
有助于添加显式类型注释。在你的情况下
appDelegate.all_breeds!.sortInPlace { (a : AppDelegate.Breed, b : AppDelegate.Breed) -> Bool in
(a.breedNameES == nil) ||
(b.breedNameES == nil) ||
(a.breedNameES! < b.breedNameES!)
}
更新到 Xcode 7 后,我的 iOS 应用程序停止编译(由于几个 "changes"),但是我想出了一些我不知道该怎么做的东西让任何更简单。我需要根据以下三个条件对数组进行排序:
appDelegate.all_breeds!.sortInPlace { (a, b) -> Bool in
(a.breedNameES == nil) ||
(b.breedNameES == nil) ||
(a.breedNameES! < b.breedNameES!)
}
基本上我需要查看西班牙语中的品种 A 是否为零,或者西班牙语中的品种 B 是否为零,否则我需要比较两个品种,并按字母顺序对它们进行排序。
在我更新到 xCode 7 之前,这一直没有问题,现在我得到的错误是
Expression was too complex to be solved in reasonable time;
consider breaking up the expression into distinct subexpressions.
问题是我不能把它分解成子表达式,这是我能想到的最基本的。
有解决这个问题的想法吗?
问题的一部分显然是 Breed 是我的 AppDelegate 中的一个结构,它迫使编译器遍历所有结构以找到它。这使得表达式需要更多时间来编译。
错误信息
Expression was too complex to be solved in reasonable time
可能有多种原因。一是编译器无法推断出 自动从上下文中提取表达式类型。在那种情况下 有助于添加显式类型注释。在你的情况下
appDelegate.all_breeds!.sortInPlace { (a : AppDelegate.Breed, b : AppDelegate.Breed) -> Bool in
(a.breedNameES == nil) ||
(b.breedNameES == nil) ||
(a.breedNameES! < b.breedNameES!)
}