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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I need to create timers in another thread (not on main):
@implementation AppDelegate {
NSThread* _worker;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
_worker = [[NSThread alloc] initWithTarget:self selector:@selector(main) object:nil];
[_worker start];
}
- (void)main {
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(timer_tick:)
userInfo:nil
repeats:YES];
[NSThread sleepForTimeInterval:INFINITY];
NSLog(@"**********************");
}
- (void)timer_tick:(NSTimer*)timer {
NSLog(@"%@", NSThread.currentThread);
}
The timer never gets fired. What's wrong with my code?
In XCTestCase, I write data to a file "/tmp/somefile", but the file does not exist in /tmp when I do ls in Terminal.
Where is the file actually created?
NSDate* now = [NSDate date];
// How get midnight time of now?
I don't know when/why my assistant editor opened on bottom. I don't have any idea how to get it back to its original position (on right side). It's annoying.
It seems I can declare variables like below in a source file:
private let var1 = 1234
fileprivate let var2 = "abcd"
class MyClass {
// ...
}
So what's the difference between the 2 vars here?
I can't believe this. I am not able to remove the following garbage items:
Right clicking does not provide any menu items to remove the garbage items.
I came across a useful repo on GitHub:
https://github.com/GianniCarlo/DirectoryWatcher/blob/master/Sources/DirectoryWatcher/DirectoryWatcher.swift
self.queue = DispatchQueue.global()
self.source = DispatchSource.makeFileSystemObjectSource(fileDescriptor: descriptor, eventMask: .write, queue: self.queue)
self.source?.setEventHandler {
[weak self] in
self?.directoryDidChange()
}
self.source?.setCancelHandler() {
close(descriptor)
}
self.source?.resume()
How do I translate this to OC version? I have an app that was written in OC and I plan to incorporate this directory watcher into the project.
I want to implement a stack that works quite like a circular buffer.
void** pp = malloc(sizeof(id) * 100);
pp[index] = someObject;
// later on somewhere:
MyObject* myObj = (MyObject*)pp[index];
Is this correct? Does this approach work with ARC?
The following code won't work:
- (void)windowDidLoad {
[super windowDidLoad];
self.window.isVisible = NO;
}
The only main window still shows on application startup (in a minimal newly created app).
One of my published apps in App Store relies on this behavior which had been working for many years since I started Xcode development.
Topic:
UI Frameworks
SubTopic:
AppKit
I don't get any idea why I am getting the following warnings when I tried to upload one of my apps:
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store
App Submission
After upgrading to Xcode 16.3, whenever I open the Documentation window, Xcode started CPU hungry mode, forever.
Does anyone else have the same experience as me? Is there any known remedy so far?
Topic:
Developer Tools & Services
SubTopic:
Xcode
This question is related to this post (of mine).
It seems default build settings do not include dSYM files needed when uploading embedding app package. But now Xcode issues new warnings about this.
Now the question - how do I tell Xcode to create dSYM files for me, say when I build My.Framework?
I asked AI chatbot which tells me that for release build I need to :
set "Debug Information Format" to DWARF
set "Strip Debug Symbols During Copy" to off
I have item 1 turned on (which I believe is the default). But item 2 is on, maybe that's the reason I do not have dSYM files in final built My.Framework.
Should I turn "Strip Debug Symbols During Copy" off?
I get many warnings like this when I build an old project.
I asked AI chatbot which gave me several solutions, the recommended one is:
var hashBag = [String: Int]()
func updateHashBag() async {
var tempHashBag = hashBag // make copy
await withTaskGroup(of: Void.self) { group in
group.addTask {
tempHashBag["key1"] = 1
}
group.addTask {
tempHashBag["key2"] = 2
}
}
hashBag = tempHashBag // copy back?
}
My understanding is that in the task group, the concurrency engine ensures synchronized modifications on the temp copy in multiple tasks. I should not worry about this.
My question is about performance.
What if I want to put a lot of data into the bag? Does the compiler do some kind of magics to optimize low level memory allocations? For example, the temp copy actually is not a real copy, it is a special reference to the original hash bag; it is only grammar glue that I am modifying the copy.
I currently do not want to upgrade to macOS 26, but I still want to install the latest Xcode. Is it required to install macOS 26 if I were to get Xcode 26?
Topic:
Developer Tools & Services
SubTopic:
Xcode