Post

Replies

Boosts

Views

Activity

Xcode 13.2 and Github - No Packages listed
I connected Github to Xcode 13.2 (Monterey macOS) successfully, however I do not see any packages available when I select Github as the source. I did download Xcode 13.2 from the developers website and it did fix some problems I was having with Xcode from the App Store but did make any difference to the issue above. Anybody else have this issue with Xcode 13.2?
4
0
1k
Dec ’21
How to save an Image to NsData object and then retrieve.
My environment is as follows: Xcode 12, macOS BS developing a macOS app. I have an IBOutlet from a IB window as @IBOutlet weak var imageView: NSImageView! So, I want to store imageView to a NSData object and then save the NSData object in my UserDefaults. Once I saved the Image in my UserDefaults I need to be able to decode or retrieve the image for use in other parts of the app. How is this done? Also, I have seen some cautions about converting an Image to NSData object and retrieving. It seems the retrieved image may not be 100% as it was originally. Is this true and if so why? Thanks
2
0
999
May ’21
NSPrintInfo design report
I am developing an macOS Xcode 12 app that requires printing. I have a basic understanding how to implement printing, I understand that I need to create a subclass of NSview to get going. However, I was wondering how to go about designing the report? Is this done with interface builder like designing a window layout or is all done with code, ie supplying position (x,y), headings, font, graphics, font size.. etc. How is this done? Also, does anybody have any tutorials on this? I have one example but it is very minimal print out, basically it prints a tableview with two columns. I got this from Coca Programming chapter 27, Big Nerd Ranch.
5
0
881
Apr ’21
TableView not populating?
I have the following code in a viewController: extension InvoicesDetailController: NSTableViewDelegate {     fileprivate enum CellIdentifiers {         static let lineItemLabelCell = "lineItemLabelCell"         static let lineItemDescCell = "lineItemDescCell"         static let lineItemAmountCell = "lineItemAmountCell"         static let lineItemQtyCell = "lineItemQtyCell"     }     fileprivate enum fieldIdentifiers {         static let lineItemLabel = "lineItemLabel"         static let lineItemDesc = "lineItemDesc"         static let lineItemAmount = "lineItemAmount"         static let lineItemQty = "lineItemQty"     }   func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) - NSView? {         let currentItem = invoiceItems[row]         var text: String = ""         var cellIdentifier: String = ""         let currentColumn = tableColumn?.identifier.rawValue         if currentColumn == fieldIdentifiers.lineItemLabel {             text = currentItem.lineItemLabel!             cellIdentifier = CellIdentifiers.lineItemLabelCell         }         if currentColumn == fieldIdentifiers.lineItemDesc {             text = currentItem.lineItemDesc!             cellIdentifier = CellIdentifiers.lineItemDescCell         }         if currentColumn == fieldIdentifiers.lineItemAmount {             text = currentItem.lineItemDesc!             cellIdentifier = CellIdentifiers.lineItemAmountCell         }         if currentColumn == fieldIdentifiers.lineItemQty {             text = currentItem.lineItemQty!             cellIdentifier = CellIdentifiers.lineItemQtyCell         }         if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: self) as? NSTableCellView {             print(cell.textField?.stringValue)             cell.textField?.stringValue = text             print(text, cell.textField?.stringValue)             return cell         }         return nil     } I have used this code (similar code in other places and it works fine, however in this case the tableView Cells are not being populated. When I look at this code using debugger the line if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: self) as? NSTableCellView always sets cell to nil? Since I don't see anything wrong with code I suspect there is an issue with the IB? Any ideas how to fix or how to debug further?
1
0
523
Mar ’21
Populate one column based on values of other column in a NSTableView
How do you populate one column based on values of other column for a macOS app using Xcode 12 in a tableView? The value of the first column comes from a comboBox which I get control by using the following code connected to the comboBox: @IBAction func comboAction(_ sender: NSComboBox) {         print("Combo selected", sender.selectedTag(), sender.stringValue, sender.indexOfSelectedItem, sender.identifier as Any)         } Then base on the value of the comboBox column within the comboAction function I want to populate column 2. Can this be done? If so, how
3
0
674
Mar ’21
How to get control from a combo box selection?
Using a combo box after a selection I want to get control to take some actions based on the selection after press tab or return in the field. I have tried a few controls like the one below: // textShouldEndEditing     func control(_ control: NSControl, textShouldEndEditing fieldEditor: NSText) - Bool {         print(#function,control.tag) But the above control only gets control if the field is edited. I want control once tab, an item selected or return is pressed while on the filed. How is this done?
2
0
514
Mar ’21
How to use combo box cell in a tableView
I have a test app with a tableView that has a comboBoxCell for one of the columns in Xcode 12: The view controller code is as follows: // //  ViewController.swift //  ComboBoxExample // //  Copyright © 2016 yourCompany. All rights reserved. // import Cocoa class ViewController: NSViewController, NSComboBoxCellDataSource {     var states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware",                   "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",                   "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi",                   "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico",                   "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania",                   "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",                   "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"]     @IBOutlet weak var itemComboCell: NSComboBoxCell!     override func viewDidLoad() {         super.viewDidLoad()         itemComboCell.usesDataSource = true         itemComboCell.dataSource = self         self.itemComboCell.completes = true         // Do any additional setup after loading the view.     }     override var representedObject: Any? {         didSet {         // Update the view, if already loaded.         }     }     func numberOfItemsInComboBoxCell(in comboBoxCell: NSComboBoxCell) - Int {       // anArray is an Array variable containing the objects         return states.count     }     func comboBoxCell(_ comboBoxCell: NSComboBoxCell, objectValueForItemAt index: Int) - Any {         return (states[index])     } } When running the example I get the following error: 2021-03-05 15:16:29.940373-0600 ComboBoxExample[40515:1914724] *** Illegal NSComboBoxCell data source (ComboBoxExample.ViewController: 0x600000e501b0).  Must implement numberOfItemsInComboBoxCell: and comboBoxCell:objectValueForItemAtIndex: How do I resolve this?
6
0
1.2k
Mar ’21
How to use NSSpellChecker and NSTextCheckingController?
I have been looking for information on how to implement NSSpellChecker and NSTextCheckingController the last couple of days and have come up empty. Does anybody of some information using these two AppKit API's or even better an example on using them with an IBOutlet text field? I understand Apple use to make available the source code for textEdit app? Does anybody know if this is still the case? Thanks
5
0
1.2k
Nov ’20
The Class is not key value coding compliant?
I have a macOS app that contains a tableView. The tableView has 7 columns and is populated from a SQLite table. The tableView displays data for 6 of the 7 columns. On the last column I get the following error:valueForUndefinedKey:]: this class is not key value coding-compliant for the key itemUsedLast. The problem was in the following code:     func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {         let identifier = tableColumn?.identifier         //   print(#function,identifier, items[row], identifier?.rawValue)         let str = items[row].value(forKey: identifier!.rawValue)         //  let str = items[row].identifier!)         return str     } When I comment out this code it works fine. Any thoughts on how to debug further?
2
0
3.1k
Nov ’20
This class is not key value coding-compliant error
My environment is as follows: macOS Catalina Xcode 12 StoryBoard Single Window/View Controller - the view controller has custom code to populate a tableView in the View Controller The tableView has 7 columns and is populated from a SQLite table. The tableView displays data for 6 of the 7 columns. On the last column I get the following error: valueForUndefinedKey:]: this class is not key value coding-compliant for the key itemUsedLast. I have searched for information on this error and what I have found is it seems to be saying that for the field itemUsedLast can not find an outlet? But in the case for a tableview the only IBOutlet is one for the entire tableView. Also, the identifiers in the storyboard match the code in the custom view controller. I have completed several tableViews before and have not run into this issue. I have tried several remedies but none resolved this issue. Any thoughts on how to debug this further or resolve this will be appreciated. Thanks
14
0
3.5k
Nov ’20
Unexpected results from code in extension viewWillAppear
Using Xcode 12 and for a macOS program. I created a test project to run down this error. The test app simply has a window controller/view controller that I added a search tool bar item to. While running searchFieldToolbarItem.view line of code crashes due to nil value. The class hierarchy from the debugger has the baseNSObject at the third level where as I was expecting this a the first level. I have this same code in another app and in debugger it shows baseNSObject at the top level. What am I missing and any ideas how to fix this? import Cocoa var custSearchField: NSSearchField = NSSearchField() class ViewController: NSViewController { 		override func viewDidLoad() { 				super.viewDidLoad() 				// Do any additional setup after loading the view. 		} 		override var representedObject: Any? { 				didSet { 				// Update the view, if already loaded. 				} 		} 		override func viewWillAppear() { 		 guard let toolbar = self.view.window?.toolbar else { 						return 				} 				guard let searchFieldToolbarItem = toolbar.items.last else { 						return 				} 				custSearchField = (searchFieldToolbarItem.view as? NSSearchField)! } }
3
0
534
Oct ’20
Unexpected behavior with Xcode 12 split view Controller?
I have the following code in a simple macOS test app using Xcode 12 and IB. It has one split view window and the only code is the code below. I built it to learn how to allow a user to change background colors for a window. This code works fine in a single Window/View Controller. However, when I try the same code in a split Window/View Controller the action code (changeColor) does not get called. Does any body know way this is the case as well as how to get this code working with a split screen controller. class ViewController: NSViewController { 		let colorPanel = NSColorWell() 		override func viewDidLoad() { 				super.viewDidLoad() 				self.view.wantsLayer = true 				self.view.layer?.backgroundColor = NSColor.gray.cgColor 				// Do any additional setup after loading the view. 		} 		@IBAction func changeBKColor(_ sender: NSButton) { 				colorPanel.activate(true) 				colorPanel.action = #selector(changeColor) 		} 		@objc func changeColor(_ sender: NSButton?) { 				print("Layer is", self.view.layer!) 					self.view.layer?.backgroundColor =	colorPanel.color.cgColor }
3
0
372
Sep ’20