Help with IOS apprentice book 2 list with swift 3:

Ok so I know swift 3 is out and right now the book is on swift 3 but I usually can figure it out to change it but this time I cant for the IOS list, can anyone help me? The original swift 2 code from the book was:

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) → Int {
return 1
}
override func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) → UITableViewCell {let cell = tableView.dequeueReusableCellWithIdentifier( “ChecklistItem”, forIndexPath: indexPath)
return cell }

When I fixed it, it worked fine except it gave a “method does not override any method from its superclass” error

There are a few changes in Swift 3, very noticeably in table views: cellForRowAtIndexPath is now cellForRowAt, NSIndexPath is now IndexPath, and heightForRowAtIndexPath is similarly now heightForRowAt. Don’t forget to check docs in Xcode when you come up against these issues - it has the new API signatures and autocomplete should help you out too.

Thank you! But still cant get it to work! The error went away but the app wont show any of the rows like it should

Have you set a breakpoint inside the delegate/datasource methods? When rows don’t appear but I know there is data it is usually because I have forgotten to make the datasource and delegate relationships in interface builder.

BTW, while you are learning you would probably make it easier on your self to use a release version of Xcode. I like to try out the latest stuff too but having to deal with Swift 3 conversions at the same time as working through tutorials is probably not helping you learn.

1 Like