I'm trying to follow this tutorial and add this to my app. However there were some problems so I tried recreating the project exactly from scratch in Xcode. The same problems keep coming up.
Firstly in the SidePanelViewController in the TableViewCell class that declare the IBOutlets
class AnimalCell: UITabelViewCell {
@IBOutlet weak var animalImageView: UIImageView!
@IBOutlet weak var imageNameLabel: UILabel!
@IBOutlet weak var imageCreatorLabel: UILabel!
func configureForAnimal(animal: Animal) {
animalImageView.image = animal.image
imageNameLabel.text = animal.title
imageCreatorLabel.text = animal.creator
}
}
do not show up in storyboard, so when I click on AnimalCell these IBOutlets should be there for me to connect in my TableView located in my Left and Right View Controllers, but nothing shows. The only IBOutlets that will work or allow me to create connection in StoryBoard is if the object is the actual view controller.
I tried using the assistant editor control dragged the UI elements and connect them regardless and eventually the dot in the circle shows its connected even though it still remains blank displaying in my Storyboard Outlets connections list, (but if I closedown and reopen xcode i have to do this again). If I compare this to both final project and the starter project downloaded from the website this is not correct. In the starter project from the website the IBActions and IBOutlets were pre-connected so they display in storyboard fine its just if I try to do this from scratch, I can't understand, why don't they display in Xcode in my Outlet connections list? (Even when I cut and paste the code from SidePanelViewController from the downloaded version from the website directly into mine still doesn't work).
Secondly when I actually run the project on the simulator it throws 2 errors in My App Delegate file and in my SidePanelViewController and it seems to highlight
let cell = tableView.dequeueReusableCellWithIdentifier(TableView.CellIdentifiers.AnimalCell, forIndexPath: indexPath) as AnimalCell
the full function is
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
tableView.dequeueReusableCellWithIdentifier(TableView.CellIdentifiers.AnimalCell, forIndexPath: indexPath) as AnimalCell
cell.configureForAnimal(animals[indexPath.row])
return cell
}
and in the App Delegate I get the same Thread 1: Exc_BreakPoint (code=Exc_I386_BPT, sub code = 0x0) and this on the line
class AppDelegate: UIResponder, UIApplicationDelegate {
Also the error I think might also be in
SidePanelViewController @objc
protocol SidePanelViewControllerDelegate {
func animalSelected(animal: Animal)
}
The final version downloaded from the website runs in the simulator perfectly fine, no errors. But its all the same code so I'm confused as to why the version I recreate is not working. Also when I complete the code using the downloaded starter project the left panel slides but the puppies button is acting as the left button as well, so its not sliding to the right, but no errors on running in the simulator come up though compared to the one I recreated from scratch.
I've deleted the contents in the derived data, deleted Xcode, installed as fresh even reverted back to 6.1 as 6.1.1 sourcekit was crashing more frequently than 6.1.
I'm very confused as to whats going on and why the original code set out in the tutorial does not work when I do it, but the downloaded final version works. I can't figure out what I'm doing wrong. I am new to Xcode and Swift. Can anyone help?
You've probably forgot to set AnimalCell
as the class for the cell in the storyboard.
You'll need to select the cell and in the Utilities Sidebar, go to the Identity Inspector and fill in the Class field with AnimalCell.
Command + Option + 3 will take you directly to the correct screen.