问题描述
我的代码在Xcode 6.2中运行良好.在更新到Xcode 6.3之后,我遇到了一些Nullabilty错误.
My code worked fine in Xcode 6.2. After the update to Xcode 6.3 I had some Nullabilty Errors.
下载Parse SDK 1.7.1之后,我可以解决这些错误.因此,我在项目中删除了旧的Parse框架文件,然后将新文件粘贴到该文件中.另外,我将代码转换为最新的Swift语法编辑/转换/最新的Swift语法".现在,我对Nullabilty错误没有任何疑问,但还有其他几个问题.在我的项目中,我有一个简单的Tableviewcontroller,其中包含以下代码:
I could solve these errors after I downloaded the Parse SDK 1.7.1. So I deleted the old Parse framework files in my project and pasted the new ones into it. Additional I convert my code to the latest swift syntax "Edit/Convert/latest swift syntax". Now I haven't problems with Nullabilty Errors but several others.In my project I have a simple Tableviewcontroller with the following code:
import UIKit
class HaendlerTableViewController: PFQueryTableViewController {
// Initialise the PFQueryTable tableview
override init!(style: UITableViewStyle, className: String!) { //1. Falialbe initialize init/style:className:)' cannot override a non-failable initializer
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Configure the PFQueryTableView
self.parseClassName = "Haendler"
self.textKey = "name"
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery! { //2. Ovverriding method with selector queryForTable has incompatitble typ () -> PFQuery
var query = PFQuery(className: "Haendler")
query.orderByAscending("name")
return query
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject) -> PFTableViewCell { //3. Ovverriding method with selector 'tableView:cellForRowAtindexPath:object:' has incompatible type '(UITableView, NSIndexPath, PFObject) -> PFTableViewCell
var cell = tableView.dequeueReusableCellWithIdentifier("HaendlerCell") as! HaendlerCell!
if cell == nil {
cell = HaendlerCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
}
// Extract values from the PFObject to display in the table cell
cell.haendlerName.text = object["name"] as! String!
var thumbnail = object["logo"] as! PFFile
var initialThumbnail = UIImage(named: "haendler")
cell.haendlerBild.image = initialThumbnail
cell.haendlerBild.file = thumbnail
cell.haendlerBild.loadInBackground()
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var detailScene = segue.destinationViewController as! HaendlerDetailViewController
// Pass the selected object to the destination view controller.
if let indexPath = self.tableView.indexPathForSelectedRow() {
let row = Int(indexPath.row)
detailScene.currentObject = objects[row] as? PFObject //4. Could not find an overload for 'subscript' that accepts the supplied agruments
}
}
}
我在代码右侧的注释中写了错误, 以下.
I wrote the errors in a comment on the right side of the code and below.
- Falialbe初始化init/style:className :)'无法覆盖非失败的初始化器
- 带有选择器queryForTable的遍历方法的类型()-> PFQuery不兼容
- 具有选择器'tableView:cellForRowAtindexPath:object:'的遍历方法具有不兼容的类型'(UITableView,NSIndexPath,PFObject)-> PFTableViewCell
- 找不到接受提供的agruments的'subscript'超载
当我从Parse Quickstart中创建一个新的Swift项目并添加一个Tableviewcontroller时,我遇到了相同的错误.在我的旧项目中,我删除了一个Objective-C桥接标头,因为我有机会直接在我的Swift项目中添加Parse SDK 1.7.1,所以我删除了它.
I have the same errors when I make a new Swift project from the Parse Quickstart and add one Tableviewcontroller. In my old project was an objective-C bridging header which one I deleted because I had the oppurtunity to add the Parse SDK 1.7.1 directly in my Swift project.
现在我需要帮助,因为我看不到要更改的内容.
Now I need help because I don't see what I have to change..
PS:对不起,德语和英语代码的混合,一旦项目再次运行,我会对其进行调整
PS: Sorry for the mix of German and English code I'll adjust it once the project is running again
推荐答案
存在相同的问题.
要解决第一个初始化问题,请删除!"在'override init'之后.应该看起来像这样:
To solve the first initialise issue remove the '!' after 'override init'. Should look like this:
// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String!) { //1. Falialbe initialize init/style:className:)' cannot override a non-failable initializer
super.init(style: style, className: className)
}
对"PFQuery"之后的第二个错误执行相同的操作
Do the same for the 2nd error after 'PFQuery'
override func queryForTable() -> PFQuery {
希望它会有所帮助.由于通常需要对最新更新的拆包元素进行修订以解决可能的错误.
Hope its helpful. Since the latest update unwrapping elements usually needs to be revised for possible errors.
这篇关于解析SDK 1.7.1在Xcode 6.3中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!