I have spotted my mistake!
When setting up the Cocoa Touch Class, I was not observant enough!
I chose UICollectionViewCell and I should have chosen UIViewController.
Post
Replies
Boosts
Views
Activity
Would this be the reason?
2021-03-18 17:54:41.850809+0000 LetsEat2[11993:109147] [Storyboard] Unknown class _TtC8LetsEat222locationViewController in Interface Builder file.
2021-03-18 17:54:41.878913+0000 LetsEat2[11993:109147] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[UIViewController 0x121a05cb0 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.'
How do I solve the error?
I don't think you are understanding what I mean!
If I have Main.Storyboard and locationViewController open in the tab bar with only the storyboard in the window. I then select the icon to open Assistant, it displays UIViewController.h and not the locationViewController.swift.
If I click the LocationViewController in the document outline pane it says no Assistant results, therefore I can't make the connection into the LocationViewController class.
I believe if I sort out this connection correctly it may solve the error I get.
Thank you for your reply
I did as you explained for the IBOutlets but still did not work, but noticed that the calcBMI fund had a circle by it so I linked it to the button and yes it did work then.
At least I learnt something from this post, that the circles on the IBOutlet and IBAction lines indicate that the actions are not linked to the textbook or buttons in the storyboard and if they have a dot in them they do!
Is this right?
When I click on the swift file in the first window (left) and then click on Assistant I get 2 swift files but the one on the right is an incomplete version of the code. The original one says no selection and the one on the right says Interface.
Still can't open both storyboard and the Swift file?
If I have the storyboard open and click Assistant it says No Assistant Results.
If this second copy of the swift file is a error how do I get rid of it? I have searched in finder an can only find one in my project.
Eventually found that out! It seems that the previous method was more straight forward, because you have to add this then delete the launch screen and make the tab controller the launch screen?
How do you close a thread?
Its me! I stupidly missed an IBOutlet for the segmented control.
Need new glasses!
I am learning from Ahmed Sahar's book and some of this explainations are not very clear. In the size inspector the Estimate size by default was Automatic, but where he showed the sizes he had changed it to None. I did not spot that first time through, but when I meticulously went through the instructions I noticed that it had been changed.
I have tried all of the above suggestions and I still get the same error.
Here is the code after modification:
//
// FirstViewController.swift
// CalorieCounter
//
// Created by Tony Hudson on 11/04/2021.
//
import UIKit
var userAge: Double?
var userWeight: Double?
var userGender: String = "Female"
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBOutlet weak var yourAge: UITextField!
@IBOutlet weak var yourWeight: UITextField!
@IBOutlet weak var segmentedControl: UISegmentedControl!
@IBAction func genderButton(_ sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
userGender = "Female"
case 1:
userGender = "Male"
default:
return
}
}
@IBAction func savePersonalInfo(_ sender: UIButton) {
userWeight = Double(yourWeight.text ?? "0.0") ?? 0.0
userAge = Double(yourAge.text ?? "0.0") ?? 0.0
}
}
Has anyone got ant other ideas?
Can't spell spelt Restaurant as resturant?
Definitely need a new pair of glasses!
Luckily this is an exercise from a book and the files are available online. I copied the file and pasted it in the project and No errors?
Still can't see what caused the error, so if anyone can find why the error occurred please let me know.
Unfortunately the only code that was available had some extra func's, so not an exact match. But as I exited the project to retrieve the code, would that have cleared the cache?
I know how to open the file in IB that is not the problem!
By using the method you describe I now open the ExploreViewController.swift, but that is not the file I need to open.
In the book it says I need to open the ExploreCell.swift.
As I mentioned previously the ExploreCell.swift was created by creating a folder called View, as a sub folder of Explore and then creating a new Cocoa Touch file called ExploreCell.swift.
What it is actually doing is opening the top level view controller in the ExploreViewController scene.
I hope this makes sense as it is hard to explain.
With this information can anyone explain how I can open this Assistant view so that I can create the connection with the label button.
Firstly, I have heard about xib files, but have never had to use them.
I have searched in Xcode but can't find how you open the xib files. I have looked through all of the tabs for Xcode.
The swift file name is ExploreCell.
Is the error caused by not doing something previously?