Post

Replies

Boosts

Views

Activity

Reply to What is the future of Objective-C?
Well Apple has pretty much dropped Objective-C and moved fully to Swift and SwiftUI becuase its faster and better to use. Worth learning it though. Interesting claims. When you say faster are you talking about performance or the speed in which you scratch your code? While it's obvious Apple is recommending Swift all the new AppKit API I'm aware of (or at least care about) for macOS 26.0 is available to Objective-C and I'm grateful or that. And how do you define better to use? Do you think the compiler gives better/more descriptive warning/error fixes in Swift than Objective-C? What about viewing variables in the debugger? What about compiler speed? I will continue to use Objective-C until I can't. My policy is currently this: -Any Swift only frameworks that are required (like Storekit2) must be wrapped inside its own framework or library. -All Swift code must be private API. All public API is Objective-C. -Main project remains Objective-C and continues on like Swift doesn't exist. Do I recommend this for new devs? No but that has more to do with Apple's public statements. It has nothing to do with Swift being "better" in any measurable way for me. I suspect one day that may change and I won't be able to use Objective-C anymore or I'll have to get an Objective-C runtime from GNUStep or something. Or maybe I'll just move to Electron or Flutter.
Topic: Programming Languages SubTopic: General Tags:
Oct ’25
Reply to App Group Not working as intended after updating to macOS 15 beta.
May seem like a dumb question but I'm somewhat overwhelmed by the amount of information and all the terms and conditions as it relates to this topic. There are several threads about cross platform issues, etc. as it relates to app groups but that is not my situation. Not too long ago I asked a similar question about a different app (not new but an update) and I just stuck with the group prefix on that one but I'd like to know what the recommendation is for a new Mac app. So I have this simple situation: I have a new Mac app. Two versions: Mac App Store (sandboxed) Non-Mac App Store (not sandboxed). They both use XPC service embedded in the app. XPC service + main app need an app group. Both non-MAS and MAS use app groups with their own XPC services (not with each other) I always used teamIdprefix.groupidentifier. So I configured and registered the group identifier for the outside the Mac App Store version because Xcode prompted me to. I'm using group. prefix (iOS style group). It seems to work fine. Is that the correct way for outside the Mac App Store? If I don't use group. prefix Xcode display the identifier in red like something is wrong. And for the Mac App Store version, is it now recommended to use iOS style groups from now on? Can the recommendation on this topic be simplified to always use the iOS style app group (group prefix not team id prefix) and only use team id prefix for historical reasons if you already have a deployed app using the old style? Or am I misunderstanding something? Thanks a lot.
Topic: Privacy & Security SubTopic: General Tags:
Oct ’25
Reply to XPC: too many nested collections when explicitly decoding a single collection on macOS 12.7 (not on macOS Tahoe)
Going to try NSSet *classesSet = [NSSet setWithObjects:[NSArray class], [MyCustomClass class], nil]; _arraypropertyOfOtherClass = [aDecoder decodeObjectOfClasses:classesSet forKey:@"myKey"]; instead of -decodeArrayOfObjectsOfClasses:forKey: but I have to archive and notarize again and then send to the Mac with 12.7 to test. Will let everyone know if it works. Would be great to get a macOS simulator someday :)
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’25
Reply to XPC: too many nested collections when explicitly decoding a single collection on macOS 12.7 (not on macOS Tahoe)
So using -decodeObjectOfClasses:forKey: with the NSArray class and the custom class (like I mentioned in the above post) works on macOS 12.7. // in the -initWithCoder NSSet *classesSet = [NSSet setWithObjects:[NSArray class],[MyCustomClass class],nil]; _arraypropertyOfOtherClass = [aDecoder decodeObjectOfClasses:classesSet forKey:@"myKey"]; Not sure when -decodeArrayOfObjectsOfClasses:forKey: started working but beware of this if you are deploying back to 12.7, you can't use -decodeArrayOfObjectsOfClasses:forkey: with XPC.
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’25
Reply to NSCollectionLayoutBoundarySupplementaryItem background blur covering the entire layout section
I suggested looking at clipsToBounds b/c I recently ran into a situation that looks very similar to your second screenshot when modifying a project that uses NSCollectionView. In my case the issue occurred when the layout used a footer view. The footer view implemented drawRect: and was filling the dirty rect. The project was written (not originally by me) but long before clipsToBounds was exposed as public API. Setting clipsToBounds to YES on the footer view stopped the issue from occurring. It was not my initial thought to check clipsToBounds because all the system blurring mixed in with the semi transparent fill color the footer view used made me think the issue was caused by something else. When I changed the footer view background color to something that stood out more like NSColor.purpleColor it made it more obvious. I first tried all sorts of other tricks. So I figured this story may be worth sharing. If you are able to narrow your issue down to something else it would be great if you shared here for knowledge building.
Topic: UI Frameworks SubTopic: AppKit Tags:
Oct ’25
Reply to Spotlight Shows "Helper Apps" That Are Inside Main App Bundle That Are Not Intended to Be Launched By The User
Thanks a lot for responding. Why are you using "/Contents/Applications/"? TBH I can't remember exactly why because I set this up ~7-8 years ago. I think I might've used this path because the helper app declares NSServices in the Info.plist and I was unable to get the these services to appear in the Services menu until I changed the path to /Contents/Applications/ I could be remembering wrong and maybe just switching the path would resolve but is Spotlight indexing required to get the .app's NSServices to appear in the Services menu?
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSCollectionLayoutBoundarySupplementaryItem background blur covering the entire layout section
the semi-transparent blur bleeds into the entire section. I just ran into this in one of my apps after scrolling a collection view a bit. Luckily I was attached to the debugger and was able to debug the view hierarchy. I discovered it to be an instance of a private class called NSScrollPocket which gets added to the NSScrollView. I set it hidden with: po (void)[0x977e0b480 setHidden:YES]; The blur over the section went away. Then I called setHidden:NO and it came back. Usually the scroll pocket appears to be near the top where the pinned section header is but I guess sometimes they have one over the entire section rectangle. So maybe we can workaround with an NSScrollView subclass like: -(BOOL)_isPotentialSubviewOuttaPocket:(NSView*)subview { Class scrollPocketClass = NSClassFromString(@"NSScrollPocket"); return (scrollPocketClass != nil && [subview isKindOfClass:scrollPocketClass]); } -(void)didAddSubview:(NSView*)subview { [super didAddSubview:subview]; if ([self _isPotentialSubviewOuttaPocket:subview]) { // outta pocket subview.hidden = YES; } } But if AppKit sets the hidden property on the scroll pocket at various times maybe we need to just prevent NSScrollPocket from entering the view hierarchy..meh or perhaps we can use a sledgehammer to make sure instances of NSScrollPocket remain hidden. might have to put it on the grill and sizzle, I mean swizzle that thing
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSCollectionLayoutBoundarySupplementaryItem background blur covering the entire layout section
But still when transitioning back with my NSPageController to the collection view the pinned header is hidden until the transition completes but I was able to mitigate that issue by calling invalidateLayout() briefly after the navigation starts. I noticed a similar issue - headers are sometimes misplaced when they are shown for the first time (headers can be toggled in my app). I'm actually using the old flow layout still so it may be a different issue but the headers snap in place after scrolling a bit. In my case calls to invalidateLayout etc. didn't reliably help. Fixing stuff after performSelector: afterDelay worked but is ugly and I want to avoid. For me I had better success just calling -performBatchUpdates:completionHandler: with a nil updates block. My original plan was to try to fix the frames in the completionHandler which ought to be called after layout is actually ready but simply calling performBatchUpdates:completionHandler: and doing nothing seems to kick it in gear. I guess I'll have to test more to be sure though. I also use the -performBatchUpdates:completionHandler: with the nil updates block to do things like restoring scroll position which you can only do when the layout is ready.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSCollectionLayoutBoundarySupplementaryItem background blur covering the entire layout section
For me I had better success just calling -performBatchUpdates:completionHandler: with a nil updates block. Maybe scratch that. I'm able to restore scroll position properly after a previous reloadData call in the completionHandler: the but sometimes header views are still misplaced. After inspecting index paths for visible items and index paths for header view etc. it seems that these index path collections are completely out of whack and are nowhere near the visible collection view region. Appears there is some kind of bug in NSCollectionView where visible index paths and visible header views are not updated to match the visible region. Seems to occur when the collection view is updated/scrolled ~viewDidAppear so I'm probably experiencing the same bug when it comes to the header views not be properly shown. Also was surprised to discover that there are some situations where NSCollectionView won't call the completion block with -performBatchUpdates:completionHandler: so whatever code you put in there could potentially get dropped (shouldn't it always call the completion block and pass NO for the finished flag?). I might just umm stay away from that...
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSCollectionLayoutBoundarySupplementaryItem background blur covering the entire layout section
Fixing the header view frames like this seems to work. NSSet <NSIndexPath*> *theIndexPaths = [collectionView indexPathsForVisibleSupplementaryElementsOfKind:NSCollectionElementKindSectionHeader]; for (NSIndexPath *aIndexPath in theIndexPaths) { NSView *headerView = [collectionView supplementaryViewForElementKind:NSCollectionElementKindSectionHeader atIndexPath:aIndexPath]; NSView *headerViewSuperview = headerView.superview; NSCollectionViewLayoutAttributes *headerLayoutAttributes = [collectionView layoutAttributesForSupplementaryElementOfKind:NSCollectionElementKindSectionHeader atIndexPath:aIndexPath]; if (headerView != nil && headerViewSuperview != nil && headerLayoutAttributes != nil) { NSRect headerViewRect = headerView.frame; NSRect targetRect = [headerViewSuperview convertRect:headerLayoutAttributes.frame fromView:collectionView]; if (!NSEqualRects(targetRect, headerViewRect)) { headerView.frame = targetRect; } else { // frame okay } } else { os_log_fault(OS_LOG_DEFAULT, "Header view in visible region not properly set up."); } } I'll probably wrap it in a category method
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSScrollView two finger drag being interrupted
Did you ever find a solution to this? I'm running into an issue where two finger scrolling on a Magic Trackpad can occasionally be interrupted. In my case the documentView is only scrollable vertically. But there is a situation (intentionally) where some subviews of the document view are positioned outside of the visible region on the x-axis (say extended a bit beyond NSMaxX of the visibleRect or before before NSMinX, not too many views though). We can call this a "row" of subviews. When the mouse is hovered over this row on the Y-axis (with the views off screen) when vertical scrolling first starts scrolling can be interrupted. I tried all sorts of things like setting clipsToBounds YES on the a bunch parent views and even the document view itself thinking drawing outside the visible area has something to do with this laggy scroll. This only occurs with two finger drag on a Magic Trackpad (not sure about Magic Mouse because I don't have one) but I have a non-Apple scroll wheel mouse and vertical scrolling never seems to be interrupted. At first I though my -scrollWheel override did it so I took it out and it but the problem still occurs.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSScrollView two finger drag being interrupted
so it looks like if one subview of the document view extends past its NSMaxX(self.bounds) even partially two finger drag scrolling can stutter when scrolling is initiated from around this area of the scroll view. I don't want to widen the document view because I actually don't want horizontal scrolling in this case
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25
Reply to NSScrollView two finger drag being interrupted
I'm not sure if our issues are exactly the same but in my case when scrolling gets stuck the scroll bar also remains visible like it's paused until I mouse click and the scroll position jumps for all the skipped frames. I dk if they are pausing a private CADisplayLink or something erroneously. Something not nice is going on with NSScrollView here! A subview sticking out partially on a horizontal edge slightly seems to trigger it for me. So regardless of whether or not I have subviews sticking out on the right or left edge of the scroll view it seems I can achieve "butter vertical scrolling" simply by overriding -scrollWheel: in the 'document view' subclass and moving the scroll point myself without calling super.... -(void)scrollWheel:(NSEvent*)event { CGFloat deltaY = (event.hasPreciseScrollingDeltas) ? event.scrollingDeltaY : event.scrollingDeltaY * self.enclosingScrollView.verticalLineScroll; NSRect currentVisibleRect = self.visibleRect; CGPoint scrollPoint = currentVisibleRect.origin; scrollPoint.y = scrollPoint.y - deltaY; [self scrollPoint:scrollPoint]; } I wish I didn't spend half a day on this!!!!
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’25