convertBaseToScreen method now deprecated

My old code uses convertBaseToScreen which is now deprecated. Although I don't use this code in my app anymore due to removal of feature, I was wondering to main old code should I plan to bring this feature back, Is there anyway I can get helpful folks here to help change the code?

- (void) updateAdWindow
{
    NSPoint origin = [window convertBaseToScreen:NSMakePoint( (window.frame.size.width - adWindow.frame.size.width)/2, 0)];
    origin.y -= adWindow.frame.size.height;

    if( closed )
        [adWindow setFrame:NSMakeRect(origin.x, origin.y, WIN_SIZE_WIDTH, 0) display:TRUE];
    else
        [adWindow setFrame:NSMakeRect(origin.x, origin.y, adWindow.frame.size.width, adWindow.frame.size.height) display:TRUE];
}

I cannot test this unfortunately and the replacement new method seem very different from the old one. How to convert?

Answers


The NSWindow method: convertRectToScreen: does not have a compatible signature with convertBaseToScreen: so it may be helpful to use the following NSWindow category method:

@implementation NSWindow (ExileTriage)

- (NSPoint) convertPointToScreen:(NSPoint)point
{
    NSRect convertRect = [self convertRectToScreen:NSMakeRect(point.x, point.y, 0.0, 0.0)];
    return NSMakePoint(convertRect.origin.x, convertRect.origin.y);
}

@end

Apple's documentation says:

Use convertRectToScreen: instead.

Convert window.frame and use the result to calculate origin.


Need Your Help

NetworkStream.DataAvailable slow to update

c# tcp tcp-ip networkstream

I am writing a basic TCP/IP server to receive messages from an existing Client. Currently, I am able to receive single- and multi-buffer messages. The problem comes when the client sends a set of