[英]Xcode 8.0 beta 6, Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'CGSWindow' (aka 'int')
Seems I'm having some growing pains associated with the Xcode 8 beta and 64bit migration. 似乎我对Xcode 8 beta和64位迁移有一些烦恼。 In searching I've found a few related questions but not one specifically related to solving an 'NSInteger' (aka 'long') to 'CGSWindow' (aka 'int') error. 在搜索中,我发现了一些相关的问题,但与解决“ NSInteger”(aka“ long”)到“ CGSWindow”(aka“ int”)错误无关。
Anyone here know how to get it going the right way round? 这里的任何人都知道如何使其正确地运转吗?
here's an example: 这是一个例子:
#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;
}
Look at the documentation for NSWindow initWithContentRect:styleMask:backing:defer:
. 查看NSWindow initWithContentRect:styleMask:backing:defer:
的文档。 What is the type for the styleMask
parameter? styleMask
参数的类型是什么?
- (instancetype)initWithContentRect:(NSRect)contentRect
styleMask:(NSWindowStyleMask)style
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag;
So you need to change NSInteger
to NSWindowStyleMask
. 因此,您需要将NSInteger
更改为NSWindowStyleMask
。
Now look at the documentation for NSWindowStyleMask
. 现在查看NSWindowStyleMask
的文档。 NSBorderlessWindowMask
is not one of the listed values (it's an old, deprecated value). NSBorderlessWindowMask
不是列出的值之一(它是一个过时的旧值)。 Use NSWindowStyleMaskBorderless
. 使用NSWindowStyleMaskBorderless
。
So your code should be: 因此,您的代码应为:
- (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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.