Instruments reveals that the following simple code leaks memory on each delegate invoke:
- (void)start {
[_urlSession dataTaskWithURL:_url];
}
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data {
[_data appendData:data];
}
I don't have any clue on this leak, it should not happen. What should I do to avoid this?
Post
Replies
Boosts
Views
Activity
Is there any way to keep an NSWindow always on top of other windows (inside an app)?
I want to create a "preview" window for pictures and videos with it not taking up space in the main window.
Does Swift/objc provide builtin support for reading/writing xcstrings, like PropertyListEncoder/PropertyListDecoder?
Does "natural scrolling" system preference affect NSEvent.scrollingDeltaY?
BTW, I find that "natural scrolling" on my Sonoma (Mac mini m1) stops working; turning on/off has no effect when I scroll in Finder app.
I accidentally removed the Fixed Width preset item in the font panel (by dragging it out).
Is there any way to get it back?
I am no expert at coordinate systems. I am kind of aware I can use its enclosingScrollView but don't know the details.
Any suggestions would be appreciated.
Today the Connect page asks me to confirm if I am a trader or not under DSA.
I am an independent developer and have several apps in App Store. I have no idea what a trader is.
The DSA defines a trader as “any natural person, or any legal person irrespective of whether privately or publicly owned, who is acting, including through any person acting in his or her name or on his or her behalf, for purposes relating to his or her trade, business, craft or profession.” If you have questions about your status as a trader, consult with your legal advisor.
I emailed Connect support but their reply is very "official" which confuses me more.
According to the doc:
The value returned is the same as the value returned in the kEventParamKeyCode when using Carbon Events.
So where can I find kEventParamKeyCode?
I have a tableview with a column which has an inner tableview. I want to change height of the outer tableview to match the height of the inner tableview.
outerTableView.reloadData()
let range = outerTableView.rows(in: summaryTableView.superview!.visibleRect)
outerTableView.noteHeightOfRows(withIndexesChanged: IndexSet(integersIn: range.lowerBound..<range.upperBound))
The above code will cause an exception:
WARNING: NSTableView detected a rowView was requested from inside of the -heightOfRow delegate method. That is not supported!
(
0 CoreFoundation 0x000000019093eccc __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000190426788 objc_exception_throw + 60
2 AppKit 0x000000019420be98 -[NSTableRowData _availableRowViewWhileUpdatingAtRow:] + 0
3 AppKit 0x000000019425a470 -[NSTableView viewAtColumn:row:makeIfNecessary:] + 32
I have an uncommon scenario here.
outer tableview
+--------------------------+
| column 1| inner tableview|
+--------------------------+
Now most often the out tableview has many rows and vertical scrollbar visible.
When user try to scroll vertically in the inner tableview but it has no vertical scrollbar (because it has only a few items), I want the scroll event sink into its parent view or better outer tableview, so that user does not have to move cursor to first column in outer tableview and scrolls.
Is this possible?
What unit does NSView.bounds/frame use? Pixel or point? How to convert between them?
I have a custom Objective-C ObjectCache class that utilized NSMutableDictionary to store named objects (specifically large NSImage objects).
The class has a maxItems property and clear method, which worked fine.
- (void)clear
{
@synchronized(_cache)
{
[_cache removeAllObjects];
}
}
But yesterday I received a customer feedback complaining one of my app consumes up to 24GB memory.
I verified that on my M1 Mac mini, and it's true. Even after calling clear method, memory usage shown in both Xcode debugger panel and Activity Monitor remains the same.
It did work before. Once I close a picture gallery window by calling clear method, memory usage dropped immediately as shown in Activity Monitor.
I suspect that this is a bug in ARM architecture. Does anyone else have same problem?
I tried many ways but it seems I just cannot get it working.
// AppDelegate
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
true // false does not work either
}
// MainWC
func windowShouldClose(_ sender: NSWindow) -> Bool {
print(#function)
if sender === NSApp.mainWindow {
print("is main window")
sender.setIsVisible(false)
return false
}
return true
}
Once I hide the main window (using setIsVisible or orderOut) the app quits; even if I return false from applicationShouldTerminateAfterLastWindowClosed, NSApp.mainWindow will become nil.
I calculate cell view's width in func tableView(_ tableView: NSTableView, sizeToFitWidthOfColumn column: Int). I have a need to resize the tableview's width to just match total width of all cell views' (without scrollbars).
But it seems changing tableview's width does not work:
tableView.bounds.size = CGSize(width: w, height: tableView.bounds.height)
I suspect that I should change its clipping view or enclosing scrollview, but don't have any idea on this.
Any help?
I use ProcessInfo.processInfo.environment["key"] to get test parameters, but all of a sudden I could not find the UI like below:
In the screenshot above, the 2 environment variables were actually what I entered for the unit test target. I don't have any idea why they were moved there!
Any similar problems?