class MovIE { var Title: String init(Title: String) { self.Title = Title }}func movIEFromDictionary(dict: Dictionary<String,AnyObject>) -> MovIE? { switch dict["Title"] { case .some(let movIETitle as String): return MovIE(Title: movIETitle) default: return nil }}
Bitcast requires both operands to be pointer or neither %38 = bitcast i8* %37 to %sS,!dbg !161InvalID operand types for ICmp instruction %39 = icmp ne %sS %38,null,!dbg !161PHI nodes must have at least one entry. If the block is dead,the PHI should be removed! %42 = phi i64,!dbg !161PHI node operands are not the same type as the result! %41 = phi i8* [ %38,%34 ],!dbg !161LLVM ERROR: broken function found,compilation aborted!Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift Failed with exit code 1
有趣的是编辑器似乎对代码没问题.这是编译器错误还是代码有问题?
解决方法 我同意评论者这是一个编译器错误,你应该向苹果报告.但是,您也可以通过这种方式实现它,这更简单,应该可以正常工作:func movIEFromDictionary(dict: Dictionary<String,AnyObject>) -> MovIE? { if let Title = dict["Title"] as? String { return MovIE(Title: Title) } else { return nil }}总结
以上是内存溢出为你收集整理的Swift switch case编译错误全部内容,希望文章能够帮你解决Swift switch case编译错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)