gpt4 book ai didi

objective-c - Xcode 8.0 beta 6,隐式转换丢失整数精度: 'NSInteger' (aka 'long' ) to 'CGSWindow' (aka 'int' )

转载 作者:行者123 更新时间:2023-12-03 17:48:30 29 4
gpt4 key购买 nike

我似乎遇到了一些与 Xcode 8 beta 和 64 位迁移相关的成长烦恼。在搜索中,我发现了一些相关问题,但没有一个专门与解决“NSInteger”(又名“long”)到“CGSWindow”(又名“int”)错误相关的问题。

这里有人知道如何让它以正确的方式进行吗?

这是一个例子:

#import <Cocoa/Cocoa.h>

@interface CustomWindow : NSWindow {
// this point is used in dragging to mark the initial click location
NSPoint initialLocation;
}

@property (assign) NSPoint initialLocation;

@end


#import "CustomWindow.h"

#import <AppKit/AppKit.h>

@implementation CustomWindow

@synthesize initialLocation;

/*
In Interface Builder, the class for the window is set to this subclass. Overriding the initializer
provides a mechanism for controlling how objects of this class are created.
*/
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag {

// Using NSBorderlessWindowMask results in a window without a title bar.
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
if (self != nil) {
// Start with no transparency for all drawing into the window
[self setAlphaValue:1.0];
// Turn off opacity so that the parts of the window that are not drawn into are transparent.
[self setOpaque:NO];
}
return self;
}

最佳答案

查看 NSWindow initWithContentRect:styleMask:backing:defer: 的文档。 styleMask 的类型是什么?参数?

- (instancetype)initWithContentRect:(NSRect)contentRect
styleMask:(NSWindowStyleMask)style
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;

所以你需要改变NSIntegerNSWindowStyleMask .

现在查看 NSWindowStyleMask 的文档。 NSBorderlessWindowMask不是列出的值之一(它是旧的、已弃用的值)。使用NSWindowStyleMaskBorderless .

所以你的代码应该是:

- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSWindowStyleMask)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag {

// Using NSBorderlessWindowMask results in a window without a title bar.
self = [super initWithContentRect:contentRect styleMask: NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
if (self != nil) {
// Start with no transparency for all drawing into the window
[self setAlphaValue:1.0];
// Turn off opacity so that the parts of the window that are not drawn into are transparent.
[self setOpaque:NO];
}
return self;
}

关于objective-c - Xcode 8.0 beta 6,隐式转换丢失整数精度: 'NSInteger' (aka 'long' ) to 'CGSWindow' (aka 'int' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39046040/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com