Post

Replies

Boosts

Views

Activity

"Invalid parameter not satisfying: [constraint isKindOfClass:[NSLayoutConstraint class]]"
I am learning Xcode from a book 'iOS Programming for Beginners' and although I am sure I entered the text correctly I get the following error when I click on the Location button. The code builds with out error, so I don't know where the error is! Here is the code: // //  LocationViewController.swift //  LetsEat3 // //  Created by Tony Hudson on 27/04/2021. // import UIKit class LocationViewController: UIViewController, UITableViewDataSource {     @IBOutlet weak var tableView: UITableView!     override func viewDidLoad() {         super.viewDidLoad()     }     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) - Int {         10     }     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {         let cell = tableView.dequeueReusableCell(withIdentifier: "locationCell", for: indexPath)         cell.textLabel?.text = "A Cell"         return cell     } } cal=n anyone explain why I get this error?
4
0
3.9k
May ’21
What replaces there Tabbed template in Xcode 12?
I am a beginner trying to learn Xcode from a book, but its out of date (written for iOS 10, Swift 3). I shows a template called Tabbed, which is not in the latest version os Xcode. I found a Tab Bar Controller but that does not set up the views as shown in the book. I tried creating a standard single view app then added the Tab Bar Controller which added a set of 3 Tabbed view controllers (master + Item 1 & item 2) and reading the book it should have created a Swift file for each of the scenes. But it did not create any. Next you were supposed to create a third scene and link it to the master Tab Bar Controller. This did have the basic View Controller code. As this does not work exactly as the old version how I produce the correct swift code for the 2 item tab view controllers. Do I just copy the Class files for the one that I added as the Third view controller and rename them FirstViewController.swift and SecondViewController.swift? I'm worried that the automated creation of files may create back office code and the method I suggest may not work correctly. The book I am using is: Beginners Guide to iOS 10 App Development Using Swift 3 by S Yamacli.
5
0
2.3k
Apr ’21
Missing bracket??
I have checked this code until I am 'blue in the face', but I can't see why I get an error saying missing closing bracket. // //  ExploreDataManager.swift //  LetsEat3 // //  Created by Tony Hudson on 16/04/2021. // import Foundation class ExploreDataManager {     func  fetch() {         for data in loadData() {         print(data)     } }     fileprivate func loadData() - [[String: AnyObject]] {         guard let path = Bundle.main.path(forResource: "ExploreData", ofType: "plist"), let items = NSArray(contentsOfFile: path) else  {             return [[:]]         }         return items as![[String: AnyObject]]     } } If I add an additional bracket it then reports an additional 'Expected '}' in class? I have counted 5 opening brackets and 5 closing brackets. I even checked to see whether I had mistakenly typed the wrong type of bracket elsewhere in the code! Is this a bug? If not what is the reason. for this error?
5
0
1.4k
Apr ’21
Collection view not displaying Cells
I am trying to learn Xcode using iOS 14 Programming for Beginners. I have just entered the code to add the images and titles on the explore screen and have checked the code with the code written by the author and it is correct. When the Explore screen opens in the simulator it should show the images with titles on the screen. All that I get is the header at the top! I have checked the connection for the IBOutlets and the have the dot in the circle, so they are connected. The code builds OK, so I am not sure what is wrong? How can I find what is causing this problem? I have not mastered debugging yet, would this help? Here is the ExploreCell.swift //  ExploreCellCollectionViewCell.swift //  EatOut // //  Created by Tony Hudson on 02/06/2021. // import UIKit class ExploreCell: UICollectionViewCell {     @IBOutlet weak var lblName: UILabel!     @IBOutlet weak var imgExplore: UIImageView! } Here is ExploreItem.swift //  ExploreItem.swift //  EatOut // //  Created by Tony Hudson on 02/06/2021. // import Foundation struct  ExploreItem {     var name: String     var image: String }     extension ExploreItem {         init(dict: [String:AnyObject]) {             self.name = dict["name"] as! String             self.image = dict["image"] as! String         }     } Here is ExploreDataManager.swift //  ExploreDataManager.swift //  EatOut // //  Created by Tony Hudson on 02/06/2021. // import Foundation class ExploreDataManager {     fileprivate var items: [ExploreItem] = []     func fetch() {         for data in loadData() {             items.append(ExploreItem(dict: data))         }     }     fileprivate func loadData() -> [[String: AnyObject]] {         guard let path = Bundle.main.path(forResource: "ExploreData", ofType: "plist"), let items = NSArray(contentsOfFile: path) else {             return [[:]]         }         return items as! [[String: AnyObject]]     }     func numberOfItems() -> Int {         items.count     }     func explore(at index:IndexPath) -> ExploreItem {         items[index.item]     } } I think that is as much information that I can give! Can someone point me in the right direction so that I can solve this problem?
9
0
3.1k
Jul ’21
Assistant not opening the correct swift file
I am trying to open the swift file so that I can Ctrl + Drag from the image cell into the swift file that I generated. The file was generated by New File - Cocao Touch class, previously. With the main.storyboard open and then choosing Assistant, I get the ViewController.h for the scene I am in and not the ExploreCell.swift file that I have just generated. The book I am following as I am a beginner, says that I should set the file as automatic but I can't seem to be able to do that. What am I doing wrong?
11
0
3.8k
Jul ’22