Does SwiftUI now have a NavigationButton? And if not, what is it replaced by?
Post not yet marked as solved
Hi everyone,
I am studying SwiftUI on the Apple tutorial - https://developer.apple.com/tutorials/swiftui/creating-a-macos-app.
In the Creating a MacOS App chapter in section 3 Update a Row View, there is a following instruction: Step 6 Choose the WatchLandmarks target to see a watchOS preview of the list.
How to do this?
It should be easy and simple, but somehow I haven't found it.
I create a Detail screen using a standard TableViewController. The TableView-Content option is Static Cells, the Table View Sell-Style option is Basic. The label is used by default, not custom. With the help of this line of code below, I try to pass a value to the label:
tableView.cellForRow(at: [0,0])?.textLabel?.text = item!.itemID
The value comes to the controller, I see it, but for some reason it is not displayed on the label and displays a nil in the debugger.
What could be the mistake?
Post not yet marked as solved
Hi everybody,
There is one strange problem in my application. When the application is launched on the phone for the first time, it does not work for the first six seconds. After that everything works fine. The app also works fine when re-launched on the phone and when launched on the simulator.
The application itself is small and not complicated, all data is stored on the device. It uses a Tab Bar Controller with three tabs. Another strange feature is that if I click on the icons in these first six seconds, then nothing works right away, but then all the commands are executed. Those, it looks like the application has accepted the commands, but it takes a long time to execute them.
Has anyone faced such a problem? What could be causing this?
Any ideas are appreciated.
Swift 5.2, Xcode 11.6, macOS Catalina 10.5.6
Post not yet marked as solved
Now I only see top posts. But it would be better to see all the new topics that have been created in recent days.
Post not yet marked as solved
Hi everybody,
I am a beginner developer and in my Shopping List application I faced a problem of a massive controller. I have read several articles on this topic. They helped me to understand some things, but they don't solve this problem completely. Therefore, I decided myself to try to organize the structure of the view controller in terms of the tasks to be solved. For example, my application has a table view controller (screen) for list of items. This TVC should perform the following main tasks:
Show list of Items.
Select items for Shopping.
In turn, the first main task includes the following actions:
Show data in a table
Supporting Edit Actions - Add, Delete, and Change Data.
Supporting Usability Action - Sort (reorder, rearrange) Data.
The second main task includes the following actions:
Mark Items with a Checkmarks
In addition, this TVC should to save and load data.
Common / General Supporting Tasks for Both Main Tasks:
Save data to the archive file
Load Data from the archive file
When I implemented all the functions of the controller, I got the following real structure:
Supporting Common / General Task: Load data
Load data from database
Load/Update data after changing in other View Controllers
Main Task 1: Show data in a table.
numberOfSections
numberOfRowsInSection
cellForRowAt
Supporting Edit Task for Main Task 1: Add a new item.
Calling a method from an Extension
Supporting Edit Tasks for Main Task 1: Delete and Change actions
leadingSwipeActions
deleteAction
changeAction
Unwind Action - Return from Change Screen for Cancel button
Supporting Usability Task for Main Task 1: Sort list of items.
Show sort/reorder/rearrange button and its title
Which rows can be reordered (Allow to reorder)
Reorder items in list
Remove Delete button from screen
Main Task 2: Select items (mark them with checkmarks)
didSelectRowAt
Supporting Usability Task for Main Task 2: Clear all Checkmarks.
Uncheck all items button
Supporting Common / General Task: Persist Data (Save data to the archive file)
Save/persist data before View will disappear
viewWillDisappear
Could you tell me is this approach optimal? May I have some other problems later which I do not know about yet?
Any ideas are appreciated.
Post not yet marked as solved
Hi everyone,can someone explain to me why, every time I reinstall the xcode, a message appears that I need to install additional components? Is this the way it should be, or is it some kind of hacker program trying to install on my computer?Any help would appreciate.
Post not yet marked as solved
Today I have reinstall Xcode (11.3.1, Catalina).As soon as I launched it, such a message appeared:Install additional required componentsXcode requires additional components to support running and debugging. Choose Install to add required components.Can someone explain to me what these additional components are? And why aren't they included in Xcode by default?Maybe there is some of the employees of the Apple company on this forum who could explain this issue? Because I have a suspicion that some malware calls itself Xcode and wants to install something harmful on my computer.
Post not yet marked as solved
I use Xcode every day. Today, a message suddenly appeared - "Developer Tools Access needs to take control of another process for debugging to continue"This has not happened before. I recently installed a clean Catalina, Xcode 11.3, swift 5.1Did anyone have such a message? Could you help me understand what to do is better in this situation?
Post not yet marked as solved
When I use Xcode it regular shows me a message "Xcode requires additional components..."It was earlier, when I used Hi Sierra and Xcode 10, and today, when I installed Catalina and Xcode 11.What is it? Is it normally or it is a problem? Can anybody help me to make clear this question?
Post not yet marked as solved
Apple has released a new book on learning to programming - AP® Computer Science Principles with Swift.What do you think about it?
For some reason, the value is lost when I try to transfer it from ViewController to TableViewController. The scheme seems to be simple, the value is taken from the first TVC (such as a warehouse) and transmitted to the VC (details), and from there to the order basket or cart - to the second TVC. And when I try to pass data to the cart, it pass only one value. I.e. if I try pass next item in Cart I see only one value in the Cart. It seems that append() method doesn't work, array always contains only one item.What is wrong here?Model:import Foundation
import UIKit
struct Bouquet {
var name: String
}First TVC:import UIKit
class BouquetsTableViewController: UITableViewController {
var bouquets = [Bouquet]()
var bouquet: Bouquet?
override func viewDidLoad() {
super.viewDidLoad()
bouquets = [
Bouquet(name: "Flower 1"),
Bouquet(name: "Flower 2"),
Bouquet(name: "Flower 3"),
Bouquet(name: "Flower 4"),
Bouquet(name: "Flower 5"),
Bouquet(name: "Flower 6")
]
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return bouquets.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "bouquetsCell", for: indexPath)
cell.textLabel?.text = bouquets[indexPath.row].name
return cell
}
// MARK: - Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard segue.identifier == "GoToDetails" else { return }
let indexPath = tableView.indexPathForSelectedRow
bouquet = bouquets[(indexPath?.row)!]
let detailsVeiwController = segue.destination as! DetailsViewController
detailsVeiwController.bouquet = bouquet
}
@IBAction func unwindToBouquets(_ unwindSegue: UIStoryboardSegue) {
}
}VC:import UIKit
class DetailsViewController: UIViewController {
var bouquet: Bouquet?
var itemToCart = ""
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var imageLabel: UIImageView!
@IBAction func addToCartButton(_ sender: UIButton) {
itemToCart = nameLabel.text!
}
@IBAction func viewCartButton(_ sender: UIButton) {
}
override func viewDidLoad() {
super.viewDidLoad()
nameLabel.text = bouquet?.name
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard segue.identifier == "addToCart" else { return }
let cartTableViewController = segue.destination as! CartTableViewController
cartTableViewController.cartItem = bouquet!
}
}Second TVC:import UIKit
class CartTableViewController: UITableViewController {
var cartItems = [Bouquet]()
var cartItem: Bouquet? {
didSet {
guard let item = cartItem else { return }
cartItems.append(item)
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cartItems.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CartCell", for: indexPath)
cell.textLabel?.text = cartItems[indexPath.row].name
return cell
}
}