nasan2092
nasan2092

Reputation: 33

Parse SDK 1.7.1 not working in Xcode 6.3

My code worked fine in Xcode 6.2. After the update to Xcode 6.3 I had some Nullabilty Errors.

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.

  1. Falialbe initialize init/style:className:)' cannot override a non-failable initializer
  2. Ovverriding method with selector queryForTable has incompatitble typ () -> PFQuery
  3. Ovverriding method with selector 'tableView:cellForRowAtindexPath:object:' has incompatible type '(UITableView, NSIndexPath, PFObject) -> PFTableViewCell
  4. Could not find an overload for 'subscript' that accepts the supplied agruments

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: Sorry for the mix of German and English code I'll adjust it once the project is running again

Upvotes: 3

Views: 803

Answers (2)

Lucas Del Rio
Lucas Del Rio

Reputation: 11

Had the same issues.

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)
}

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.

Upvotes: 1

justColbs
justColbs

Reputation: 1872

I had the same issue as I just updated Xcode to 6.3 about 20 minutes ago.

For your 2nd error, remove the '!' after 'PFQuery'. So it should now look like.. override func queryForTable() -> PFQuery {

This solved my problem in regards to that specific error.

I never used an init method as you did in your first error, but try removing it and see what you get. My PFQueryTableViewController works fine without it.

Upvotes: 1

Related Questions