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
Post
Replies
Boosts
Views
Activity
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?
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?
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.
Anybody else having problems with app icon on Xcode 12 not showing up for a macOS app?
Is there a way to add an image to a post on the Forum?
I am using Xcode 11.6 and IB for a macOS app and using a tableview. It has 10 columns. I would like to add the functionality to right click on the header and have a pop menu with the column names to select which columns for the tableview to show/hide. What is the best approach to add this functionality? How is this done?
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
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?
How to grant access to Users Documents folder from a sandbox Xcode 11 macOS app. I want the app to be able to open an existing file (without using NSOpenPanel) in the users document directory. I have looked through the apple sandbox doc and don't see a way to do this.
How is this done?
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?
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?
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
}
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
}
}
Using Interface Builder with Xcode 11 I have created two windows, when I activate the second window it opens as a tab in the main window. How do I change this to start a second window instead of a tab?