In my OS X app I'm trying to fetch application's support directory. But I'm getting wrong results.
using:
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)
returns
///Users/chandresh/Library/Application%20Support/
instead
/Users/chandresh/Library/Containers/com.thinkbizz.ThinkBizz-Business-Dynamics/Data/Library/Application%20Support/
Although, it returns correct result while using SandBox.
It doesn't give me correct path without SandBox
Post
Replies
Boosts
Views
Activity
Hello,
I was running macOS app on old iMac. But when I tried to run the same code on MacBook Air M1 on Monterey I receive following error.
I tried searching solution everywhere, but no solution has been found.
Please help if anyone able to resolve this issue.
Translated Report (Full Report Below)
Incident Identifier: 656E6540-596D-4ACC-98E1-3B3339992FF0
CrashReporter Key: 8EC66A36-1996-E656-76D7-FE1144ACDA5D
Hardware Model: MacBookAir10,1
Process: ThinkBizz Business Dynamics [16320]
Path: /Users/USER/Library/Developer/Xcode/DerivedData/ThinkBizz_Business_Dynamics-byvoiahkkwoisueapzfaqupjnobh/Build/Products/Debug/ThinkBizz Business Dynamics.app/Contents/MacOS/ThinkBizz Business Dynamics
Identifier: com.ThinkBizz.TBD
Version: 1.0 (1)
Code Type: X86-64 (Native)
Role: Background
Parent Process: launchd [1]
Coalition: com.ThinkBizz.TBD [2258]
Date/Time: 2022-01-14 15:28:28.9350 +0530
Launch Time: 2022-01-14 15:28:28.8352 +0530
OS Version: macOS 12.1 (21C52)
Release Type: User
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL (Code Signature Invalid))
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: CODESIGNING 1
Triggered by Thread: 0
Thread 0 Crashed:
0 0x7ff7ffd5ba2c 0x7ff7ffd58000 + 14892
Binary Images:
0x7ff7ffd58000 - 0x7ff7ffd87fff (*) <21c1e0c9-a36e-3e4b-a12b-1bf54ce4403e> ???
Error Formulating Crash Report:
dyld_process_snapshot_get_shared_cache failed
EOF
I'm facing issue from few days with CloudKit. When I try to fetch any record from Cloudkit it gives me following error:
<CKError 0x6000006ec420: "Service Unavailable" (6/2022); "Request failed with http status code 503"; Retry after 30.0 seconds>
Also, when I try to query records from Cloudkit dashboard I receive "Internal error".
I have not done any write operations.
Please help if anyone has solved this type of error.
I'm using MBProgressHUD in my cocoa app(https://github.com/Foxnolds/MBProgressHUD-OSX).
It's working fine when I show on app's main window.
I'm showing new modal window using
		 NSApplication.shared.runModal(for: wc.window!)
Now, when I try to ProgressHUD above this window. It doesn't show on this modal window, instead it shows on mainWindow only and progressHUD doesn't hide also.
In my project, I've used NSCollectionView with a custom cell item. I want only a single selection on collectionView.In the collectionViewItem I've many textFields & buttons. I'm able to select a specific cell on click. But I'm not able to deselect again clicking on same cell.Though I have used following code to deselect cell:var clickGesture: NSClickGestureRecognizer!
override var isSelected: Bool {
didSet {
if isSelected {
mainBox.borderType = .lineBorder
//shortContentBox.fillColor = NSColor(red: 72/255, green: 112/255, blue: 255/255, alpha: 0.05)
mainBox.addSelectionShadow()
addGestureRecognizer()
} else {
mainBox.borderType = .noBorder
//shortContentBox.fillColor = .controlColor
mainBox.removeShadow()
removeGestureRecognizer()
}
}
}
func addGestureRecognizer() {
clickGesture = NSClickGestureRecognizer(target: self, action: #selector(onItemClick(_:)))
clickGesture.buttonMask = 0x1
clickGesture.numberOfClicksRequired = 2
view.addGestureRecognizer(clickGesture)
}
func removeGestureRecognizer() {
view.removeGestureRecognizer(clickGesture)
clickGesture = nil
}
@objc func onItemClick(_ sender: NSGestureRecognizer?) {
collectionView?.deselectAll(nil)
}My problem is, now I'm not able to click on textField or button, after selecting the cell. While I'm able to click on textField when the cell is not selected.Any suggestions? How do I achieve selection & deselection on click?
Hi, I wanted to show open file app like Xcode, before opening application's main window.Tried many ways, but didn't find any luck.
Hi, I'm trying use Formatter for NSTextField to set maximum string length.I found this https://stackoverflow.com/questions/827014/how-to-limit-nstextfield-text-length-and-keep-it-always-upper-caseBut it's for objective-c. I tried this for swift, but it's not workingfunc controlTextDidChange(_ obj: Notification) {
if let info = obj.userInfo, let text = info["NSFieldEditor"] as? NSText {
let formatter = TextFieldFormatter()
formatter.maxLength = 10
let string = text.string
text.string = formatter.string(for: string.capitalized)!
}
}Custom formatter class:class TextFieldFormatter: Formatter {
var maxLength = 0
func setMaximumLength(_ len: Int) {
maxLength = len
}
func maximumLength() -> Int {
return maxLength
}
override init() {
super.init()
maxLength = Int(Int32.max)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func string(for obj: Any?) -> String? {
return obj as? String
}
override func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?, for string: String, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool {
obj?.pointee = string as AnyObject
return true
}
override func isPartialStringValid(_ partialStringPtr: AutoreleasingUnsafeMutablePointer<NSString>, proposedSelectedRange proposedSelRangePtr: NSRangePointer?, originalString origString: String, originalSelectedRange origSelRange: NSRange, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool {
let size = partialStringPtr.pointee.length
if size > maxLength {
return false
} else {
return true
}
}
}
I have a MacOS ERP project, and I'm using Core Data to store my data.I want to create multiple core data store & configuration for each store at runtime.Is there any way achieve this?
I have an collectionView. I'm increasing it's height on selction. But, I want add animation on increasing height.How do I achieve in sizeForItemAt method.func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
if let selectedRow = selectedRow {
if selectedRow == indexPath.item {
return NSSize(width: collectionView.bounds.width, height: 572)
}
}
return NSSize(width: collectionView.bounds.width, height: 71)
}
Hello, I'm building chat app, and also using CoreData to store messages.I have rotated my collectionView, so that it looks like it's going bottom to up.I have rotated my collectionView in viewDidLoad()override func viewDidLoad() {
super.viewDidLoad()
msgsCollectionView.delegate = self
msgsCollectionView.dataSource = self
//observeUserMessages()
//rotate collectionView 180º
msgsCollectionView.transform = CGAffineTransform.init(rotationAngle: (-(CGFloat)(Double.pi)))
//move scroll indicator from right to left
msgsCollectionView.scrollIndicatorInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: msgsCollectionView.bounds.size.width - 7)
attemptFetch()
}Then, I have rotated each cell in cellForRowAtfunc collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let message = controller.object(at: indexPath)
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MessageCell", for: indexPath) as? MessageCell {
cell.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
if let messageText = message.text {
let size = CGSize(width: 250, height: 1000)
let options = NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin)
let estimatedFrame = NSString(string: messageText).boundingRect(with: size, options: options, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.darkGray], context: nil)
if !message.isSender {
cell.msgTextView.frame = CGRect(x: 8, y: 0, width: estimatedFrame.width + 16, height: estimatedFrame.height + 18)
cell.textBubbleView.frame = CGRect(x: 0, y: 0, width: estimatedFrame.width + 16 + 8, height: estimatedFrame.height + 20)
} else {
cell.msgTextView.frame = CGRect(x: collectionView.frame.width - estimatedFrame.width - 16 - 8, y: 0, width: estimatedFrame.width + 16, height: estimatedFrame.height + 18)
cell.textBubbleView.frame = CGRect(x: collectionView.frame.width - estimatedFrame.width - 16 - 8 - 8, y: 0, width: estimatedFrame.width + 16 + 8, height: estimatedFrame.height + 20)
}
}
cell.configureCell(msg: message)
return cell
} else {
return MessageCell()
}My problem is when I send a new message, the cells get reload and animated again to rotate 180ºfunc controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
if type == .insert {
blockOperations.append(BlockOperation(block: {
self.msgsCollectionView.insertItems(at: [newIndexPath!])
}))
}
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
if self.controller.fetchedObjects!.count > 0 {
self.msgsCollectionView.reloadData()
}
}Please check the output:https://imgur.com/koYLhrMHow do I avoid cell layout effect??