简体   繁体   English

Xcode 8.0 beta 6,隐式转换失去整数精度:从'NSInteger'(aka'long')到'CGSWindow'(aka'int')

[英]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.

相关问题 隐式转换失去整数精度:&#39;NSInteger&#39;(又名&#39;long&#39;)到&#39;int&#39; - Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int' 值转换问题:隐式转换失去整数精度:&#39;size_t&#39;(又名&#39;unsigned long&#39;)到&#39;int&#39; - Value Conversion issue: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' 如何删除100个警告“隐式转换失去整数精度:'NSInteger'(又名'long')到'int'”我在更新到arm64后得到了什么? - How to remove 100s of warnings “implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'” I got after updating to arm64? 隐式转换在制作应用程序时将整数精度&#39;NSUInteger&#39;(aka&#39;unsigned long&#39;)转换为&#39;int&#39;吗? - implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' when making app? 隐式转换将整数精度&#39;NSUInteger&#39;(aka&#39;unsigned long&#39;)丢失为&#39;int&#39;警告? - implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' warning? Objective-C 隐式转换失去整数精度 &#39;NSUInteger&#39;(又名 &#39;unsigned long&#39;)到 &#39;int&#39; 警告 - Objective-C implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' warning 当我加密字符串时,我得到隐式转换会失去整数精度:&#39;unsigned long&#39;到&#39;CC_LONG&#39;(aka&#39;unsigned int&#39;) - When I encrypt the String I get Implicit conversion loses integer precision: 'unsigned long' to 'CC_LONG' (aka 'unsigned int') Arc 不允许将“nsinteger”(又名“long”)隐式转换为“nsstring *” - Implicit Conversion of 'nsinteger' (aka 'long') to 'nsstring *' is Disallowed with Arc 不允许将&#39;NSInteger&#39;(又名&#39;unsigned int&#39;)隐式转换为&#39;NSNumber *&#39; - Implicit conversion of 'NSInteger' (aka 'unsigned int') to 'NSNumber *' is disallowed with arc 与指针转换不兼容的整数将&#39;NSInteger&#39;(又名&#39;int&#39;)发送到&#39;NSInteger *&#39;类型的参数(又名&#39;int *&#39;) - Incompatible Integer to pointer conversion sending 'NSInteger' (aka 'int') to parameter of type 'NSInteger *' (aka 'int *')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM