Hi,
I'm working on integrating iCloud Drive functionality into my app. I noticed that the folder for my app appears under /Users/USERNAME/Library/Mobile Documents/MY_CONTAINER, but it doesn't show up in iCloud Drive.
Am I missing a step in the setup or configuration? Any guidance would be appreciated!
Thanks!
Post
Replies
Boosts
Views
Activity
Hi,
I'm using NSPanel that his level is .popUpMenu and when I use .quickLookPreview in SwiftUI it make the the Quick Look behind the nspanel how can I fix it without change the level of NSPanel?
Hi,
I made a "Finder view" with SwiftUI, how is it possible to call viewModel.selectFileWithAnimation(file) when .contextMenu show?
Thank you!
@StateObject private var viewModel = FilesViewModel() // Use the view model to manage data and logic
var body: some View {
VStack {
// Horizontal scrolling of files and folders
ScrollView(.horizontal, showsIndicators: false) {
if viewModel.sortedAndFilteredFolderContents.isEmpty {
// Show "No Results" if no files or folders found
Text("No Results")
.font(.headline)
.foregroundColor(.almostWhite)
.padding()
} else {
HStack(spacing: 20) {
ForEach(viewModel.sortedAndFilteredFolderContents, id: \.self) { file in
VStack {
ZStack {
// Selection effect without matchedGeometryEffect
if viewModel.selectedFile == file {
RoundedRectangle(cornerRadius: 10)
.fill(Color.blue.opacity(0.2))
.transition(.opacity)
.frame(width: 80, height: 100)
.animation(.easeInOut(duration: 0.3), value: viewModel.selectedFile)
}
VStack {
Image(nsImage: viewModel.getFileIcon(for: file))
.resizable()
.frame(width: 64, height: 64)
.onTapGesture(count: 2) {
// Select and open file/folder on double-tap
viewModel.selectFileWithAnimation(file)
viewModel.openFileOrFolder(file)
}
.onTapGesture {
viewModel.selectFileWithAnimation(file)
}
.onLongPressGesture(minimumDuration: 0.5) {
// Rename file with long press
viewModel.rename(file)
}
.contextMenu {
// Define your context menu buttons here
Button(action: {
viewModel.showInFinder(file)
}) {
Text("Show in Finder")
Image(systemName: "folder")
}
Button(action: {
viewModel.moveToTrash(file)
}) {
Text("Move to Trash")
Image(systemName: "trash")
}
Button(action: {
viewModel.rename(file)
}) {
Text("Rename")
Image(systemName: "pencil")
}
Button(action: {
viewModel.makeAlias(for: file)
}) {
Text("Make Alias")
Image(systemName: "link")
}
Button(action: {
viewModel.compress(file)
}) {
Text("Compress \(file.lastPathComponent)")
Image(systemName: "archivebox")
}
Button(action: {
viewModel.copyFile(file)
}) {
Text("Copy")
Image(systemName: "doc.on.doc")
}
Button(action: {
viewModel.shareFile(file, in: dynaClip.view)
}) {
Text("Share")
Image(systemName: "square.and.arrow.up")
}
}
Text(file.lastPathComponent)
.font(.caption)
.lineLimit(1)
.truncationMode(.tail)
.frame(width: 80)
}
}
}
}
}
.padding(.top, 20)
}
}
Hi,
How can I improve the CPU usage of my auto scrolling text (horizontal)? Currently I use very short timer
Thank you
Code: https://codeshare.io/Q8A1JJ
Hi,
I just did a NSTextField with auto complete that show a cities menu bar
the problem is when I typing the first letter, the focus change to the menubar and if I try to write another letter it just replace the first letter and not add it how can I fix it?
Thank you!
class NSTextFieldAuto: NSTextField, NSMenuDelegate, NSTextFieldDelegate {
var suggestionMenu: NSMenu?
var selectedSuggestionIndex: Int?
override func awakeFromNib() {
super.awakeFromNib()
self.delegate = self
self.suggestionMenu = NSMenu()
self.suggestionMenu?.delegate = self
}
override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
// Deselect all text when the text field is clicked
}
override func textDidChange(_ notification: Notification) {
super.textDidChange(notification)
print("Still typing")
updateSuggestionMenu()
showSuggestionMenu()
}
override func textDidEndEditing(_ notification: Notification) {
print("Finished typing")
cityDef.setValue(self.stringValue, forKey: cityDefKey)
}
func updateSuggestionMenu() {
self.suggestionMenu?.removeAllItems()
let searchText = self.stringValue.lowercased()
for (index, city) in allCities.enumerated() {
if city.lowercased().hasPrefix(searchText) {
let item = NSMenuItem(title: city, action: #selector(selectSuggestion(_:)), keyEquivalent: "")
item.target = self
self.suggestionMenu?.addItem(item)
}
}
}
func showSuggestionMenu() {
if let menu = self.suggestionMenu, !menu.items.isEmpty {
let textFieldRect = self.bounds
let origin = NSPoint(x: textFieldRect.origin.x + 100.0, y: textFieldRect.origin.y + textFieldRect.size.height)
menu.autoenablesItems = false
menu.popUp(positioning: nil, at: origin, in: self)
}
}
@objc func selectSuggestion(_ sender: NSMenuItem) {
self.stringValue = sender.title
}
override func cancelOperation(_ sender: Any?) {
self.suggestionMenu?.cancelTracking()
self.window?.becomeFirstResponder()
}
func menuDidClose(_ menu: NSMenu) {
self.window?.makeFirstResponder(self) // Set text field as first responder again
print("Close menu")
}
override func becomeFirstResponder() -> Bool {
let result = super.becomeFirstResponder()
self.selectedSuggestionIndex = nil // Reset selected suggestion index
return result
}
}
I'm trying to capture audio samples from the selected output device on macOS using ScreenCaptureKit?
Thank you
Hi,
I'm using NSSplitViewController and once I load a viewcontroller with scrollview the IBActions of NSSwitch,NSButtons etc not work after I added the scrollview
How can I fix it?
import Foundation
//Categories Protocal delegate
protocol CategoriesViewControllerDelegate: AnyObject {
func didSelectCategory(category: String)
}
class DetailViewController:NSViewController, NSOutlineViewDataSource, CategoriesViewControllerDelegate {
weak var delegate: CategoriesViewControllerDelegate?
override func viewDidLoad() {
// Other setup code...
detViewController = self
loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self)
}
func didSelectCategory(category: String) {
// Handle the selected category in DetailViewController
print("Selected category: \(category)")
// Load the corresponding view controller or perform any other actions
switch category {
case "General":
// Load GeneralSettingsViewController
// Example: self.replaceCurrentViewController(with: GeneralSettingsViewController())
print("Load GeneralSettingsViewController")
loadViewControllerWithScrollView(GeneralSettingsViewController.self, storyboardIdentifier: "GeneralSettingsViewController", originalViewController: self)
case "DynaMusiX":
// Load DynaMusicSettingsViewController
// Example: self.replaceCurrentViewController(with: DynaMusicSettingsViewController())
print("Load DynaMusicSettingsViewController")
loadViewControllerWithScrollView(DynaMusicSettingsViewController.self, storyboardIdentifier: "DynaMusicSettingsViewController", originalViewController: self)
case "DynaGlance":
// Load DynaGlanceSettingsViewController
// Example: self.replaceCurrentViewController(with: DynaGlanceSettingsViewController())
print("Load DynaGlanceSettingsViewController")
loadViewControllerWithScrollView(DynaGlanceSettingsViewController.self, storyboardIdentifier: "DynaGlanceSettingsViewController", originalViewController: self)
default:
break
}
}
}
//Load viewcontroller with scrollview
func loadViewControllerWithScrollView<T: NSViewController>(_ viewControllerType: T.Type, storyboardIdentifier: String, originalViewController: NSViewController) {
let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)
let newViewController = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(storyboardIdentifier)) as! T
// Remove existing child view controllers
for childVC in originalViewController.children {
childVC.removeFromParent()
childVC.view.removeFromSuperview()
}
// Wrap the new view controller's view in a scroll view
let scrollView = NSScrollView()
scrollView.documentView = newViewController.view
scrollView.autoresizingMask = [.width, .height]
scrollView.hasVerticalScroller = true
scrollView.hasHorizontalScroller = false
scrollView.contentView.scroll(to: NSPoint(x: 0, y: newViewController.view.frame.height))
scrollView.translatesAutoresizingMaskIntoConstraints = true
// Set user interaction for the content view inside the scroll view
scrollView.documentView?.translatesAutoresizingMaskIntoConstraints = true
scrollView.documentView?.needsLayout = true
// Add the scroll view as a subview of the original view controller
originalViewController.view.addSubview(scrollView)
scrollView.frame = originalViewController.view.bounds
scrollView.layer?.zPosition = -1
}
t
Hi,
How is it possible to make NSProgressIndicator smaller ?
When I use style property the thickness is also change
This is the size that I want (it's from Xcode) it's with regular size style but it's smaller in size
And this is my attempt
Hi,
How is it possible to check if I have a new mail? Is it possible to do it with ScriptingBridge?
Thank you!
How is it possible to remake the Dynamic Island music spectrum (visual EQ) animation on macOS? I see WhatsApp have a similar animation on voice calls. Is there a 3rd or native Apple library to make it?
https://imgur.com/a/PKDkosC
Hi,
What is the best way to make this animation with Swift and UIKit?
[Animation:](https://dribbble.com/shots/4247369-Loading-notch
/)
Thank you!
Hi.
Is it possible to get all Safari/Chrome open tabs with AppleScript? Is it also possible to check if tab audio is enable/play video/music?
macOS
Thank you!
Hi,
Is it possible to handle touchbar volume slider (not volume buttons)
I want to print hello when the user use volume slider on touchbar
Hi,
How can I release my NSWindow manually? when the user tap on red close button?
@objc func windowWillClose() {
// Handle the window closing event here
// You can perform any necessary cleanup or ask the user for confirmation
// Return true to allow the window to close
_window?.contentViewController = nil
_window?.delegate = nil
_window = nil
NotificationCenter.default.removeObserver(self, name: NSWindow.willCloseNotification, object: nil)
}
//Settings cell tap
@objc func settingsItemClicked () {
//_window:NSWindow?
NotificationCenter.default.addObserver(self, selector: #selector(windowWillClose), name: NSWindow.willCloseNotification, object:_window)
if _window?.isVisible == false {
// Load the view controller from the storyboard
let storyboard = NSStoryboard(name: "Main", bundle: nil)
guard let ViewController = storyboard.instantiateController(withIdentifier: "SettingsViewController") as? SettingsViewController else {
fatalError("Unable to instantiate SettingsViewController from storyboard.")
}
// _window.delegate = self
// Set the view controller as the content view controller of the window
_window?.contentViewController = ViewController
_window?.isReleasedWhenClosed = false
_window?.hidesOnDeactivate = true
// Set the window's title
_window?.title = "DynamicLake"
// Show the window
_window?.makeKeyAndOrderFront(self)
}else{
print("The settings view is already open")
}
}