Our app supports only portrait mode. And in some cases, the status bar moves horizontally, as shown in the video below. We have confirmed that this problem does not appear in OS versions 15.3.1 and lower. The problem occurs on OS 16 and 17.
https://youtu.be/CiR5LcoBI5c
At the point when the problem appears, the code simply subscribes to data through the interval scheduler. The code is below: At that point, set autoUpdate to true.
private let autoUpdateTimer = Observable<Int>.interval(.seconds(20), scheduler: MainScheduler.asyncInstance)
private var autoUpdate = BehaviorRelay<Bool>(value: false)
autoUpdateTimer
.withLatestFrom(autoUpdate)
.filter { $0 }
.withLatestFrom(Observable.combineLatest(deviceSeq,currentChannel,channel)
.map { ($0.0, $0.1, 1, $0.2?.property?.unitCount ?? 1) }
.flatMap(dependency.usecase.pubAutoStatus)
.subscribe().disposed(by: disposeBag)
I would appreciate any feedback on how I can resolve this.
AppKit
RSS for tagConstruct and manage a graphical, event-driven user interface for your macOS app using AppKit.
Post
Replies
Boosts
Views
Activity
I need to draw an attributed string into a given rectangle. The string's height should be the same as the rectangle's height. This should work with any font a user chooses. To make it a bit more complicated, the string should also fill the rect if it consists only of uppercase characters or only of lowercase characters.
I am using NSLayoutManager to find the "best" font size for the selected font and the given recht and it works quite good with some fonts but with others it doesn't. Seems like the computed font size is always a bit too small and for some fonts it seems like the baseline must be corrected. Unfortunately I didn't find a way to calculate a baseline offset that really works with any font. I attached some sample images showing the issue.
Just posting this to make sure I am not running in the complete wrong direction. Any help would be highly appreciated. Thanks!
I am use XCode 15.2 and macOS SDK 14.2.
I placed an NSView inside the NSClipView of an NSScrollView, the NSView is smaller than the NSClipView, always centered.
On Ventura, regardless of whether clipsToBounds is set, the bounds and visibleRect of the NSView are the same.
However, on Sonoma, even after overriding
-(BOOL)clipsToBounds
{
return YES;
}, the bounds is correct, but the visibleRect (the red rect) is still the same size as the NSClipView, results in the text is not clipped.
Am I missing something or doing something wrong?
How can I make the visibleRect of the NSView consistent with its bounds?
If anyone there is familiar with Cocoa, can you please help with the following issue: How to make the NSWindow resize based on the contentView? Here is a video of the problem: https://drive.google.com/file/d/19LN98xdF9OLcqRZhMJsGGSa0dgMvj_za/view?usp=sharing
Thanks!
here's my case, i develop a control widget, user can push a controlwidget to play music without open the app.
i bind a AudioPlaybackIntent to the widget. when user click the widget, the app will receive the intent and start to play music.
it works perfect when app running in background or foreground. but when app not launched, the respond is too slow, it takes several seconds to start play music.
is there any way to make the respond faster when app not launched? if i want to do something when app not launched, what should i do?
Hello,
while app icon is shown in 'Targets' app icon is not shown in 'alert panel'
What is wrong?
Best regards
Gerhard
This issue happens in my app and I don't know why, I cannot get even useful info from stack. it's all about AppKit and HIToolBox or CoreFoundation.
I initially suspect it might be related to NSTimer. However I think this wouldn't cause such a crash. I am currently out of ideas and unable to provide more detailed and effective information (if I could, that would be great, and I also hope to have it).
I search Apple Doc and it tell me NSInternalInconsistencyException occurs when an internal assertion fails and implies an unexpected condition within the called code. So I want to get some clues from you why I encounter such an issue.
@interface MyApp () {
scoped_refptr<base::SequencedTaskRunner> task_runner_;
}
@implementation MyApp
//...
- (void)start {
// ...
self.timer = [NSTimer
scheduledTimerWithTimeInterval:60 // call every 60 sec
target:self
selector:@selector(logAndKill:)
userInfo:info
repeats:YES];
- (void)logAndKill {
if (needLog) {
// ...
} else {
task_runner_->PostTask(FROM_HERE, base::BindOnce(^() {
[self.timer invalidate];
self.timer = nil;
}));
Dear all,
I'm building my first MacOs app.
I've created my app icon and add it to AppIcon folder, but when I'm building the application the icon shows in the dock of the screen with no rounded borders like all the other apps.
I'm attaching here the icon and as you can see it has sharp edges. It is the same way in which it shows on the dock.
Why? Has anybody experienced the same?
Thanks for the support in advance,
A.
I have a textfield in accessory view of NSSavePanel. For user convenience there are default actions supported natively by macOS (such as pressing Enter, keyEquivalent). However this doesn't work for enter under Sonoma. Escape key works. Is enter keypress dangerous for malicious actors so it's not supported? I have workaround below but I am not confident if I am not violating sandbox (future proof).
Original code demonstrating the issue:
class ViewController: NSViewController, NSTextFieldDelegate, NSControlTextEditingDelegate {
let savePanel = NSSavePanel()
override func viewDidLoad() {
super.viewDidLoad()
let customView = NSView()
let textField = NSTextField(string: "11111111")
textField.delegate = self // to get focus using tab keypress
savePanel.accessoryView = textField
}
override func viewWillAppear() {
savePanel.runModal()
}
}
Workaround:
// variable set to true in delegate method controlTextDidEndEditing
var didUseTextFieldWithEnterPressed = false
override func performKeyEquivalent(with event: NSEvent) -> Bool {
if #unavailable(macOS 14) {
return super.performKeyEquivalent(with: event)
}
guard let panel, didUseTextFieldWithEnterPressed == true, event.type == .keyDown &&
(event.keyCode == UInt16(kVK_Return) || event.keyCode == UInt16(kVK_ANSI_KeypadEnter)) else {
return super.performKeyEquivalent(with: event)
}
return panel.performKeyEquivalent(with: event)
}
i init a CPAlertTemplate with a CPAlertAction, on iOS17, action can called by button click, but on iOS18, action can not be called by button click.
so i can't dissmiss the alert by button click.
The documentation states that the NSApplicationDelegate function application:openURLs will replace the application:openFile call. The documentation for applicationDidFinishLaunching also states that application:openFile will be called before applicationDidFinishLaunching. Is it guarenteed therefore that applicaiton:openURLs will also be called before applicationDidFinishLaunching?
Crashed: com.apple.root.user-initiated-qos.cooperative
0 Foundation 0x4e2a4 specialized String.withUTF8(:) + 100
1 Foundation 0x4eb8c JSONWriter.serializeString(:) + 100
2 Foundation 0x4e810 JSONWriter.serializeJSON(:depth:) + 92
3 Foundation 0x4cfd4 JSONWriter.serializeObject(:depth:) + 888
4 Foundation 0x4e914 JSONWriter.serializeJSON(:depth:) + 352
5 Foundation 0xd06fc JSONEncoder.encode(:) + 624
6 Foundation 0xd0484 dispatch thunk of JSONEncoder.encode(_:) + 56
I just noticed that NSCursor.currentSystemCursor is deprecated starting in macOS 15. What method should I now use to get information about the current system cursor, including its image?
Hello,
I'm not I00% sure how to ask this, so I apologize if I word it wrong.
This is Obj-C from an older project I have. My app has a NSTableView and each cell has a button to perform and action and shows a progress bar in each cell. The issue I'm running in to is when I scroll down while a task is running the running progress bar shows running on a different cell. So if its he 2nd from the bottom and a scroll an even number of row its equivalent is now showing the progress bar.
How do I target just that one cell; making it unique?
In the recent MacOS Sequoia Beta 3 NSTextAttachment initialized with custom data and an Image cell as attachmentCell are shown as a file icon istead of the image cell.
I am creating a NSAttributedString and showing it in NSTextView like this:
NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithData:[text dataUsingEncoding:NSUTF8StringEncoding] ofType:nil];
attachment.attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:img];
NSMutableAttributedString *res = [[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
...
import Cocoa
class MyView: NSView {
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func becomeFirstResponder() -> Bool {
return true
}
override var acceptsFirstResponder: Bool {
return true
}
override func keyUp(with event: NSEvent) {
print("keyUp: keyCode=\(event.keyCode)")
}
// the 'CMD + q' combination will quit the app
// the 'CMD + t' combination will open a font setting window
// the 'CMD + Space' combination will toggle the spotlight search
// the 'CTRL + Space' combination will toggle the input method switching
// why this can't capture the key board event like 'CMD + Space' or 'CMD + t' or 'CMD + q'?
// or how capture those combinations regardless of the system-wide shortcuts?
override func keyDown(with event: NSEvent) {
print("keyDown: keyCode=\(event.keyCode)")
if event.modifierFlags.contains(.command) {
if event.keyCode == 49 {
print("keyDown: CMD + Space") // if the 'CMD' and 'Space' keys were pressed both, this line is not print
} else {
print("keyDown: CMD + others") // here, like 'CMD' and 'j' keys were pressed both, this line is print
}
} else if event.modifierFlags.contains(.control) {
if event.keyCode == 49 {
print("keyDown: CTRL + Space") // if the 'CTRL' and 'Space' keys were pressed both, this line is not print
} else {
print("keyDown: CTRL + others") // here, like 'CTRL' and 'j' keys were pressed both, this line is print
}
} else {
print("keyDown: CMD or CTRL is not pressed")
}
}
override func flagsChanged(with event: NSEvent) {
print(#function, event.keyCode)
}
}
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear() {
super.viewWillAppear()
let myview = MyView(frame: view.bounds)
view.addSubview(myview)
}
}
When using the new ‘addSymbolEffect’ effect method on NSImageView with the ‘.rotate.byLayer’ parameter with an applicable SF Symbol 6 symbol, the resulting animation is not completely as expected, to say it mildly.
This is the code line I use:
imageView.addSymbolEffect(.rotate.byLayer, options: .repeat(.continuous), animated: true)
The correct layer rotates around the correct anchor point, but the whole image is moving up and down.
The same code with the same symbol in iOS 18 beta runs perfectly.
Does anyone know how to get this new rotate API correctly working in macOS 15 beta?
In case an Apple engineer reads this:
FB13916874 contains example projects for macOS (wobbling rotation) and iOS (perfect rotation), and a screen recording what I see in macOS 15 beta.
In one of my apps, I use NSTableViewDiffableDataSource in tandem with NSFetchedResultsController, which provides the necessary snapshots. This works great in macOS 14.5.
However in latest macOS 15 betas, NSTableViewDiffableDataSource does not call the 'cellProvider' completion handler anymore when the data of a visible cell changes. When data of a visible cell changes, the didChangeContentWith method of NSFetchedResultsController is called correctly, but applying the provided snapshot doesn’t result in calling the said 'cellProvider' completion handler. This looks a rollback to the early state of this API in 2020.
It concerns this piece of code:
dataSource = NSTableViewDiffableDataSource(tableView: tableView, cellProvider: { (tableView, tableColumn, row, item) -> NSView in
// Return a cell view with data
})
Does anyone know a solution or workaround to get animated updates of visible cells working in macOS 15 beta?
Yes, applying the snapshot without animation works, but that’s not where NSTableViewDiffableDataSource is designed for.
In case an Apple engineer reads this:
Looking at the sample code associated with FB13931189, is there anything wrongly implemented that prevents calling the 'cellProvider' method for visible cells?
Is this perhaps actually a bug of NSFetchedResultsController? I’m asking this because NSCollectionViewDiffableDataSource does have a very similar problem (FB13943853).
PS
Yes, this post looks very similar to https://developer.apple.com/forums/thread/759381#759381021, because the problem is identical except that concerns NSCollectionViewDiffableDataSource.
In one of my apps, I use NSCollectionViewDiffableDataSource in tandem with NSFetchedResultsController, which provides the necessary snapshots. This works great in macOS 14.5.
However, when updating data in Core Data related to a visible item in a NSCollectionView, the NSCollectionViewDiffableDataSource no longer calls the ‘itemProvider’ closure of the diffable data source when using macOS 15 Seed 3, after applying a snapshot with animation. As a result of this, the collection view does not update visible items when the related data changes.
I’m talking about this piece of code which is no longer called when it concerns a visible item:
dataSource = NSCollectionViewDiffableDataSource<String, NSManagedObjectID>(collectionView: collectionView, itemProvider: {
// Return an NSCollectionViewItem here
})
Does anyone know a workaround or solution to get updating of visible cells working in macOS 15 Seed 3, without losing animated updates?
In case an Apple engineer is reading this:
Are there any related API changes that must be taken into account?
Is this perhaps actually a bug of NSFetchedResultsController? I’m asking this because NSTableViewDiffableDataSource does have a very similar problem in macOS 15 beta.
See also FB13943853
Hello,
I am trying to use the following code to disable the Hide option for my application :
NSApplicationPresentationOptions options = [NSApp presentationOptions];
options |= NSApplicationPresentationDisableHideApplication;
[NSApp setPresentationOptions:options];
, but it doesn't have any effect : the Hide option is still clickable :
How could I remove this option?
Thanks for any help in advance!