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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
What unit does NSView.bounds/frame use? Pixel or point? How to convert between them?
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?
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.
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?
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