Post

Replies

Boosts

Views

Activity

How to identify which NSTextFiled changed?
For a macOS Xcode 11/12 I have the following function in my view controller:  func controlTextDidChange(_ obj: Notification) { So, I want to identify the TextField/SearchField that triggered the notification. I have tired to a few things as well as looked in the debugger at obj object but don't see how to do this? How is this done? Thanks
2
0
326
Sep ’20
Trigger Event from one View Controller to another
I have a macOS app using IB/Xcode 11 with two View Controllers with each having their own custom class. The first controller contains a tableview of my datasource. The second view controller has a detail view to insert new data as in an add function. So, I would like to have an event in the first controller that gets control when the second controller inserts the new data to my SQLite table. How is this done?
4
0
960
Sep ’20
Text Fields don't appear in stack view?
I am using Xcode 11 for a macOS app. When I add a text field(s) to a window and then test, the text field shows up. However when I selected the text field(s) and use the "embed in" button for a stack view they no longer show up. I have even tried this on a test project with one label and one text field and the same thing happens. I must be missing something? Why does this occur?
3
0
2.3k
Aug ’20
Create popup menu from right click event
I would like to create a popup menu using swift coding in a macOS app from a right click event using Xcode 11 or 12. Can't seem to find an example of this. I see plenty of IOS examples but none for macOS. Does anyone have an example of this you could share or could show me how this is done. Also, I know how to add a menu to to the View Controller but this allows right click from anywhere in the tableView and I want the popup menu to show when you right click on a row in the table. If anybody is familiar with quicken for Mac I want the same function as it as when you right click on a row in an account register. Here is the code for the right click event:   // right click action     override func rightMouseDown(with theEvent: NSEvent) {     let point = tableView.convert(theEvent.locationInWindow, from: nil)         let row = tableView.row(at: point)         selectedCustomer = custviewModel.customers[row].custNumber!         print(selectedCustomer)         // Add popup menu         print("right click")         print(row)     } I have ask this question on couple of other forums as well as searched for tutorials on this and have come up empty.
12
0
4.0k
Aug ’20
How to force a window to open as a tab?
Using Xcode 11 for a macOS app and storyboards I created an app with three window controllers/view controllers. When first testing the second and third window would open in Tab of the first window, but along the way I changed something on one of the secondary windows and now that window opens in its own window. (Did not notice exactly when a change or changes caused this to happen) I have a buttons in the main window tool bar that when clicked it provides a segue to the second and third window. Also, I have tabbing mode on all three set to automatic and I have tried preferred with all windows but the second window still opens in its own window. I realize this does not contain much detail, but I was hoping someone had seen this before and could help. How can I get this window to open as a tab as it originally did? I have looked at tab view to maybe redo them but this is not exactly what I was looking to do. Thanks
0
0
401
Aug ’20
Declaring swift Type
I have the following function I am leaning from: func getAllCustomers() -> NSArray {     var rowsFetched: NSArray     do {         try dbQueue.read { db in             let custlist = try Customers.fetchAll(db)             rowsFetched = custlist             }          }     } catch {         print("\(error)")     }     return(rowsFetched) } The problem with this code is in the assignment "rowsFetched = custlist" I get the following error: Cannot assign value of type 'Customers' to type 'NSArary However, type 'Customers' is really an array. How do I fix this?
6
0
444
Jul ’20
How to debug Sqlite Error
I am getting the following error using GRDB.swift package for a macOS target. 2020-07-13 14:35:50.945023-0500 PayMe[2382:98653] [logging-persist] os_unix.c:44152: (0) open(/Users/bsoule/Desktop/TestGRDB.db3) - Undefined error: 0 Fatal error: 'try!' expression unexpectedly raised an error: SQLite error 14: unable to open database file: file /Users/bsoule/Documents/Xcode/PayMe/PayMe/AppDelegate.swift, line 21 2020-07-13 14:36:15.392148-0500 PayMe[2382:98653] Fatal error: 'try!' expression unexpectedly raised an error: SQLite error 14: unable to open database file: fil I have stepped through my program using debug/step into and can't see exactly where it is getting this error. Looking on the web it seems to be a general purpose error. Any ideas how to debug this error?
2
0
1.5k
Jul ’20
Trying to change the background color for a tableView Cell
I am Trying to change the background color for a tableView Cell when selected with the following code, however it does not work. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {         nameTextField.text = contacts[indexPath.row].name         phoneTextField.text = contacts[indexPath.row].phone         addressTextField.text = contacts[indexPath.row].address         selectedContact = indexPath.row        let cell = tableView.dequeueReusableCell(withIdentifier: "ContactCell", for: indexPath)         let bgColorView = UIView()         bgColorView.backgroundColor = UIColor.green         cell.selectedBackgroundView = bgColorView What is wrong with this code?
1
0
1.2k
Jul ’20
Can not get table to display using UITableView
I have a learning project I am working with using SQLite. I am able to create a database and insert rows, however in retrieving rows and wanting them to show up on the screen nothing appears. The section of code to view data on the screen is below. Any suggestions on how to fix? Multiline   func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "ContactCell")!         var label: UILabel?         label = cell.viewWithTag(1) as? UILabel // Name label         label?.text = contacts[indexPath.row].name         label = cell.viewWithTag(2) as? UILabel // Phone label         label?.text = contacts[indexPath.row].phone         return cell     }
2
0
377
Jul ’20
Changing View Colors
I an using Xcode 11 with IB and I have working some code to change the background colors from a ViewController class. Is there a way to a smiliar thing from the window controller?Here is the code I have in the ViewController..import Cocoa class ViewController: NSViewController { let colorPanel = NSColorWell() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override var representedObject: Any? { didSet { // Update the view, if already loaded. } } @IBAction func changeBKColor(_ sender: NSButton) { colorPanel.activate(true) colorPanel.action = #selector(changeColor) } @objc func changeColor(_ sender: Any?) { self.view.layer?.backgroundColor = colorPanel.color.cgColor } }
3
0
1.7k
Jun ’20