I'm writing a user personnal dictionary for ivritUsually, in ivrit, we don't write vowels. But for a dictionary, it is very important to save the word with vowels.So, I need to display words with or without vowels. Of course, in the Database, I write words with vowels.My question is: from a String containing vowels, how can I eliminate these vowels to display the word in a textfield without vowelsFor instance: in ivrit the word "noise" is רַעַש the signs below the letters are the vowels.so how can I write this word without vowels (רעש)?I'm not an expert manipulating unicode, I've tried many things but I don't obtain the result I want
I work for macOsx, and I have an NSWindowController which contains a NSTableViewWanting to know when the table is resized, I add an observer on the NSWIndowController:NotificationCenter.default.addObserver(self, selector: #selector(windowDidResize(_:)),
name: NSWindow.didEndLiveResizeNotification, object: self)Something I didn't understand is why when I select a row with the mouse, the didEndLiveResizedNotification is fired?
I need to display an NSTableView (through a NSWindowController) by interrogation a webServicefor one of the interrogation, the webServices return me more than hundred rows of dataSo there are 2 problems:1. the datasource takes a big amount of memory2. it can takes a long time before the datasource is entirely loadedI think the solution is to interrogate the webservice for the number of visible lines (and further to asynchronously load some other lines to prepare the scrolling).To obtain he number of visible lines, I do:let nbVisibleRows = Int(myTable.frame.size.height / (myTable.rowHeight+1))At the initialization of the window, I effectively obtains the good number of rowsMy problem is that the window can be resized.So I add and observer:NotificationCenter.default.addObserver(self, selector: #selector(windowDidResize(_:)), name: NSWindow.didEndLiveResizeNotification, object: self)and in the méthod windowDidResize I ask for the number of visible rows exactly as I wrote above.I do do understand the size of the table.frame returned in the windowDidResize methodwhen I load the window, it returns for the table a height of 277.0, wich is correctwhen I resize the window even from a very small amount, it returns for the table a height of 2886.0So I can't calculate the number of visible rowsAny idea what I did wrong?
Post not yet marked as solved
I have subclassed 3 macOS controls: NSCheckbox, NSTextField and NSButton (this one to have a checkbox) and I have override the methods resignFirstResponder and becomeFirstResponder as following:override open func resignFirstResponder() -> Bool {
Swift.print("\(identifier!.rawValue) resignFirstResponder")
return super.resignFirstResponder()
}
override open func becomeFirstResponder() -> Bool {
Swift.print("\(identifier!.rawValue) becomeFirstResponder")
return super.becomeFirstResponder()
}I thought that when I focus a control (with keyboard Tab or with a mouse click) I would have resignFirstResponder called for the control having the focus and becomeFirstResponder called for the control taking the focus.But it is not exactly like that. I get as result:identCheck becomeFirstResponder
identCheck resignFirstResponder
identText1 becomeFirstResponder
identText1 resignFirstResponderI don't understand why the method resignFirstResponder is called for identText1, after it becomed firstResponder.
Post not yet marked as solved
I'm trying to develop my own NSControl.The reasons of this are very complex, but to resume, I want my own controls reacting with a web server, in many applications, without rewrite the same libraries, over and over.But if my reasons are complex, I think my question is not so complex. The control is very simple: it needs to draw a view with white background and a defined height.My code is:import Cocoa
@IBDesignable class myTextField: NSControl {
@IBInspectable var height: CGFloat {
get{
return frame.size.height
}
set (aValue) {
let aSize = CGSize(width: self.bounds.size.width, height: aValue)
setFrameSize(aSize)
}
}
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
height = 30
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
needsLayout = true
height = 30
_init()
}
func _init() {
let aSize = CGSize(width: self.bounds.size.width, height: height)
setBoundsSize(aSize)
setFrameSize(aSize)
}
override func prepareForInterfaceBuilder() {
_init()
super.prepareForInterfaceBuilder()
needsDisplay = true
let aSize = CGSize(width: self.bounds.size.width, height: height)
setFrameSize(aSize)
}
override func draw(_ dirtyRect: NSRect) {
Swift.print("bounds \(self.bounds)")
Swift.print("Frame \(self.frame)")
var newRect = dirtyRect
newRect.size.height = height
super.draw(newRect)
NSColor.white.setFill()
newRect.fill()
}If I put a customView on my storyboard this view is designed properlyif I subclass the custom view as being a myTextfield, the background is transparent and whatever the value of the height property, the design doesn't change.When I build and run my project, the myTextfield show properly.What did I missed?
Post not yet marked as solved
I work with osx and I have 2 viewcontrollersfirst one is a list of items, second one is editing one itemin the first controller, I write:NotificationCenter.default.addObserver(self, selector: #selector(verbeModifie(_:)), name: .savenom, object: nil)savenom is defined as following:extension Notification.Name { static let savenom = Notification.Name("savenom")}and the method verbeModifie as following:@objc func verbeModifie(_ notification: Notification) { Swift.print("appel verbe modifie') } }In the second controller, I have a method when the record is modified:func notifyModifVerbe() { let info = ["idmot": String(idmot), "idtypemot": String(idtypemot)] NotificationCenter.default.post(name: .savenom, object: self, userInfo: info) }with the debugguer, I verify that notifyModifVerbe is called, but the method "verbeModifie" of the first class is never called.I work with maxOS 10.13.6 and i have to precise two things:it worked before, but the two controllers subclass classes I have put in a pod.did I miss something?
Post not yet marked as solved
I have controls and controllers that I have to include in my projects, over and overSo I wants to make a frameworkwith these controls library.I have to precise that my framework has to includeAlamofireI made the framework, but when I integrate it in a project and I subclass one of my windowControllers, I have the followin error inthe subclassed initializer: "Must call a designated initializer of the superclass 'clistWindow' "Of course, I call the superclass initializer(which is in the framework) .I tried in the subclassed initializer to call "super.init(window: nil)" but I have the error: "Argument labels '(window:)' do not match any available overloads"I don't understand because in the framework class, I have an initializerwith initialise (to nil) all the variables. IL thought it was suficient to make a designated initializer.On other thing: when I inspect the interface header of the class (I mean the .h file) I don't have this designated initializer.Any Help?
Post not yet marked as solved
I need to display a tableView without knowing all of the columns at compile time.The names, formats (and of course values) of some columns are given by a query during executing time.So I thought I have to override the make function of tableView as follow:override func make (withIdentifier identifier: String, owner: Any?) -> NSView? { if identifier != "ligne24" &&{ // "ligne24" is one of the identifier(s column I can't build on compile time return super.make(withIdentifier: identifier, owner: owner) } let view = NSTableCellView() let txt = myNewTextField() txt.identifier = identifier view.subviews.append(txt) return view }Of course, in another place of my code, I have added this:column = NSTableColumn (identifier: "ligne24")column.title = "some title"tableView.addTableColumn(column)and infunc tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?I put the correct value in the textfieldat executing time, table is ok, I can see the column named ligne24, but this column is empty even if while debugging I ca see I put the correct value in the cellAny Idea?
Post not yet marked as solved
I have a tableview with data coming from the web. I load this data, I display my tableview and everything is good except one little thing;the initial sort position is not refledted in the corresponding column headerIf I click on a column after the table is loaded, the sort is done and the header of the column has the symbol of a sorted columnBut when the table is initially loaded, no symbol appearsof course, I tried to put some instructions like: let descriptorName = NSSortDescriptor(key: "nomlocataire", ascending: true) tablesaisie.tableColumns[1].sortDescriptorPrototype = descriptorNamebut no symbol appears on the corresponding header columnWhat did I missed?
Post not yet marked as solved
I want to scan documents in my App, so I user ICDeviceBrowserIt didnt find any scanner, and I realized that I have only printers who has abilities to scan documents.Is there a mean to open and control these printers scanners, or do I have to buy a real scanner?Thank's
Post not yet marked as solved
HelloI had an application which access pdf files in some locations and launch acrobatread by opening the file:workSpace().openFile(filename)this worked fineI had to sandbox my application, in order to access contacts and the pdf fiels cannot be opened anymore, because they are not readablebRes = manager.fileExists(atPath: filename) returns truebutbRes = manager.isReadableFile(atPath: filename) return falsewhen I inspect my file, it has read/write privileges for everyoneI don't undesrtand what I am missing?
Post not yet marked as solved
Hellofor some textfield, I need to show a NSViewController through a popover, when this textfield becomes firstResponder.My problem is that the viewController displays twice: once as an independant window and once in the popover.I feel it's because I create the view using:let wc = helpViewController()and later:myPopover.contentViewController = wcSo I've tried this:let popoverViewController = storyboard?.instantiateController(withIdentifier: "helpViewController")andmyPopover.contentViewController = popoverViewControllerbut ly application crashes on the nstantiateController. I can't find helpViewController.Hoping i have told clearly about my problem, could you help me?
I have views to present to mouser which can have two states: editing or noeditingIn non editing state, the user can only see informations.textfields are not editable and not bezeled:iif the user has authorization, he can push a button in the toolbar and the view enter editing mode:in some of my views, I have a comboboxI have subclassed this combo so that in non editing mode, it is replaced by a NSTextFieldMy code is the following (I just write what I think is necessary, for bigger clarity):class myControlCombo: NSComboBox { var myHiddenText: NSTextField! var state: etatWindow = .nonedition override var stringValue: String { get { return super.stringValue } set (S) { myHiddenText.stringValue = S super.stringValue = S } } required init?(coder: NSCoder) { super.init(coder: coder) myHiddenText = NSTextField(frame: self.frame) myHiddenText.isBezeled = false myHiddenText.isEditable = false myHiddenText.font = self.font self.superview?.addSubview(myHiddenText) } override func draw(_ dirtyRect: NSRect) { if state == .nonedition { myHiddenText.draw(dirtyRect) } else { super.draw(dirtyRect) } } func setState (state: etatWindow, couleur: NSColor) { self.state = state if (state == .nonedition) { isSelectable = false //isBezeled = false isButtonBordered = false isEditable = false backgroundColor = couleur myHiddenText.isHidden = false } else { backgroundColor = couleur //isBezeled = true isButtonBordered = true isSelectable = true isEditable = true myHiddenText.isHidden = true } }}I have the following problem: in non editing mode, when the NSTextField is displayed instead of the combobox it is not properly aligned and the font is not correctAny Ideas why?
Post not yet marked as solved
I have subclassed some cells of a tableview in order to display an icon corresponding to a PDF file on my computerif I click on a row of my table, then this row is selected, this is correctbut I also want to click on the subclassed cell, in order to open the PDF file in acrobat or other readersI know how to open the file, but I don't know how to receive the mouseDown event in the subclassed cellThank's for help
Post not yet marked as solved
I have this code which operates properly:class aController: NSWindowController { func aMethod () { .... }}class aTest { var myController: aController() func test { let methodName: String = "aMethod" let method = Selector (methodName) if myController.responds (to: method) { myController.perform (method) } }}In this case, when I invoke method test of class aTest, tyhe method of class aController is always invoked.But if the method "aMethod" has parameters, I don't kown how to write my code:I have tested many possibilities, but it doesn't workSomeone to help?