How can I fix CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError:

I created a simple application which displays a window with a sample text and I'm supposed to use an alert when the user chooses to close the application, if he presses ok in the alert the application will close, if he presses cancel it goes on.

So pretty simple code, I have a window class:

//
//  MyWindow.h
//  AppTest
//
//  Created by sanya on 11/09/24.
//

#ifndef MyWindow_h
#define MyWindow_h

@interface Window : NSWindow
{
  NSTextField* label;
}
- (instancetype)init;
- (BOOL)windowShouldClose:(id)sender;
@end

@implementation Window

-(instancetype)init
{
	label = [[[NSTextField alloc] initWithFrame:NSMakeRect(5, 100, 290, 100)] autorelease];
	[label setStringValue:@"Hello, World!"];
	[label setBezeled:NO];
	[label setDrawsBackground:NO];
	[label setEditable:YES];
	[label setSelectable:YES];
	
	[label setTextColor:[NSColor colorWithSRGBRed:0.0 green:0.5 blue:0.0 alpha:1.0]];
	[label setFont:[[NSFontManager sharedFontManager] convertFont:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:[[label font] fontName] size:45] toHaveTrait:NSFontBoldTrait] toHaveTrait:NSFontItalicTrait]];

	[super initWithContentRect:NSMakeRect(0, 0, 300, 300) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
	
	[self setTitle:@"Hello world (label)"];
	[[self contentView] addSubview:label];
	[self center];
	[self setIsVisible:YES];
	return self;
}


- (BOOL)windowShouldClose:(id)sender
{
	BOOL bClose = NO;
	CFOptionFlags responseFlags = 0; 
		
	// Display the alert
	CFUserNotificationDisplayAlert(
			0, 						
			kCFUserNotificationNoteAlertLevel, 
			NULL, 
			NULL,
			NULL, 
			CFSTR("Alert Title"), 
			CFSTR("This is a message displayed in the alert."), 
			CFSTR("OK"),
			CFSTR("Cancel"),
			NULL, 
			&responseFlags 
		);
	
	
	if (responseFlags == kCFUserNotificationDefaultResponse)
	{
		NSLog(@"User clicked OK");
		bClose = YES;
	}
	else if (responseFlags == kCFUserNotificationAlternateResponse) 
	{
		NSLog(@"User clicked Cancel");
	}
	
	if( bClose )
		[NSApp terminate:sender];
	return bClose;
}

@end

#endif /* MyWindow_h */

And in the main function I just initialize it:

int main(int argc, const char * argv[]) 
{
     [NSApplication sharedApplication];
	[[[[Window alloc] init] autorelease] makeMainWindow];
	[NSApp run];
}

It seems to work but if click 'Cancel' on the dialog , xcode gives me the following warning:

CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them

So i'm obviously not doing this in the correct way, how can I fix this?

Also, any feedback on this code as a whole is highly appreciated.

How can I fix CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError:
 
 
Q