I've looked for a while and maybe it's my search parameters but can't find doing this with Swift (5). An example I've looked at I need to translate somehow ... https://searchcode.com/file/101621017/OpenEmu/OEFileManager.mSo far I've only managed to copy a file,let from_cchar = from.path.cString(using: .utf8)!
let to_cchar = to.path.cString(using: .utf8)!
let flags: copyfile_flags_t = UInt32(bitPattern: COPYFILE_DATA)
let success = copyfile(from_cchar, to_cchar, nil, flags)I need to implement COPY_QUIT but no idea how to reference the file copy ? (will be async)
Post not yet marked as solved
Is there a way to store resized images (thumbnails) in a catalog, or is it easier to just save them to a local folder ?
Post not yet marked as solved
Using an IBAction ...(_ sender: NSButton) getting the state to change a bool. However setting the state initially whilst populating a table gives oposite results ...@IBAction func addCheckValue(_ sender: NSButton) {
let object_row = tableView.row(for: sender)
lt state = sender.state
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
...
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "identCellAdd"), owner: nil) as? NSTableCellView {
if let button = (cell.subviews[0] as? NSButton) {
button.state = file.add ? NSControl.StateValue.on : NSControl.StateValue.off
}
return cellIf the state is on the action's state will be normal 1 on 0 off, but if it is off 1 becomes off and 0 on.
Post not yet marked as solved
I have a weak var WindowController which will close outside a DispatchQueue but no way inside, calling main synchronously or async ?
My brain is fried from heat, not even sure how to pose the question.I have a class that has a var let's say "var isRunning: Bool = false", within it's parent another class instance with the same var where I want it to be controlled from. If I link the two, initially it's reading the var but changing later has no affect.Sorry, I know this is probably a basic question.
Post not yet marked as solved
Using copyfile's flags, I have an example in what I assume is C but no idea what it translates to in Swift ... "flags: Int32 = COPY_ALL" but want to append "flags |= COPY_MOVE" ?
I'm still not sure when to use [weak self] within closures I do use trailing closures probably more often than I should. This question though, would I need to use it in the case of an Array Filter ?
So using let creates a strong reference, what about if let ?
Post not yet marked as solved
Is it possible to have an NSAlert show & wait for the result within a DispatchQueue.Global.Async ? Since it needs to be done on the main thread.
Post not yet marked as solved
I found I need to use Aspect Fit but can't find it anywhere in the IB. Supposedly should be under the Attributes Inspector "Mode" but this doesn't exist. I set the constraints to "Superview" which is a Box an had to set scaling to none otherwise it doesn't fill, programatrically at runtime the image will change and no constant size but doing this resizes the window's width to the new image width. The images are portrait and want to fit into landscape which is why I chose Aspect Fit no Fill.Has it been depricated or am I missing something ?
Post not yet marked as solved
Is there a Calendar View to use in a Storyboard or are they custom made ?
Post not yet marked as solved
Trying to add constraints to items within subviews, mainly left view. If I set the constraints 0,0,0,0 filling the view, the trailing space keeps messing up to the right view. Anyone had this problem and know how to fix it ?
Post not yet marked as solved
Is it possible to simulate the "beginSheetModal" (alert or opensavepanel behaviour) when presenting a view controller from a storyboard "storyboard.instantiateController" with "presentAsSheet" to have a completion closure ?
I have multiple times sorting an array so same code over and over, but I'm wanting to narrow it down to use only one function to sort the array.At the moment using ...if d { self.array.sort(by: { $0.url_path < $1.url_path }) }
else { self.array.sort(by: { $0.url_path > $1.url_path }) }Trying something similar to ...func sortArray(d: Bool, arg1: ?, arg2: ?) {
if d { self.array.sort(by: { arg1 < arg2 }) }
else { self.array.sort(by: { arg1 > arg2 }) }
}
sortArray(true, ?, ?)
Post not yet marked as solved
Can't pass an "inout" parameter as [AnyOnject] ?I have a func that passes back an array but then set another array as the return, wondering if I can point to that array without the middle man. The type of the in array is determined within the function.