Post

Replies

Boosts

Views

Activity

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
New to Xcode - Problem converting instructions from a previous version
I am new to Xcode and have found a useful book online called 'Intro to app development with Swift. It is written for Xcode 10 but I have Xcode 12.4. The instructions do not follow in the new version. In particular I want to add an image in the View Controller but I can't find anything like Image View in the Attributes Inspector. Can someone indicate. where this is so I can move on from the exercise I am doing. Also Is there an upto date book online that can help me learn Xcode?
0
0
324
Feb ’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
Could not dequeue a view of kind:
I am learning Xcode/Swift from Ahmad Sahar's book and I have an exception error: Exception NSException * "could not dequeue a view of kind: UICollectionElementKindCell with identifier restaurantCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" 0x00006000002d06c0 name __NSCFConstantString * "NSInternalInconsistencyException" 0x00000001c3059170 reason __NSCFString * "could not dequeue a view of kind: UICollectionElementKindCell with identifier restaurantCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" 0x00006000037a09c0 userInfo void * NULL 0x0000000000000000 reserved __NSDictionaryM * 2 key/value pairs 0x0000600000cf0480 The previous action that I did was to Ctrl + Drag from the exploreCell in the ExploreViewController Scene to the RestaurantListViewController Scene, creating a 'Show' Segue. As I am a beginner I am not sure what the error is telling me? Can someone help and show me where I am going wrong?
3
0
4.3k
Apr ’21