[aString drawAtPoint:withAttributes:] Works in High Sierra, does not in Mojave - Why?

Markus Ruggiero

I have written a small Cocoa program that works in High Sierra but stopped working in Mojave. The program loads a graphics file from disk and displays it full screen. At the bottom it should write the filename. The picture is shown, the rect for the filename display is properly painted in dark grey, but there is no filename shown. I did upgrade my rMBP the other day from High Sierra to Mojave and since then the filename is gone. I ran the app from Xcode and verified with the debugger that the infoString is properly set. So something must be wrong with the way I draw the string. But what? Mind you I am not a Cocoa nor an Obj-C programmer. This little app is just something to play with and learn.

This method resides inside MyCustomView.m file and is supposed to draw the infoString at the bottom of the screen inside a darkGray rectangle. The rectangle is 25 pxels high an stretches across the bottom of the screen.

- (void)drawInfo: (NSString*)infoString inRect:(NSRect)infoRect {

[[NSColor darkGrayColor] set];

NSMutableDictionary *attrs = [[NSMutableDictionary alloc] init];
[attrs setObject: [NSColor whiteColor] forKey: NSForegroundColorAttributeName];
[self lockFocus];
[infoString drawAtPoint:NSMakePoint(20.0, 4.0) withAttributes:attrs];
[self unlockFocus];

Any idea?
Thanks a lot

Join cocoa@apple-dev.groups.io to automatically receive all group messages.