Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift warning-从';内置Int32和x27;至';内置Int8和x27;_Swift_Int_Warnings - Fatal编程技术网

Swift warning-从';内置Int32和x27;至';内置Int8和x27;

Swift warning-从';内置Int32和x27;至';内置Int8和x27;,swift,int,warnings,Swift,Int,Warnings,我得到了以下警告,与发生的线路无关: warning: integer overflows when converted from 'Builtin.Int32' to 'Builtin.Int8' 此代码中出现警告: extension NSPoint { func ToString() -> String { return "(" + self.x.description + "," + self.y.description + ")" } func Plus(toBeA

我得到了以下警告,与发生的线路无关:

warning: integer overflows when converted from 'Builtin.Int32' to 'Builtin.Int8'
此代码中出现警告:

extension NSPoint {

func ToString() -> String {
    return "(" + self.x.description + "," + self.y.description + ")"
}

func Plus(toBeAdded : NSPoint) -> NSPoint {
    return NSPoint(x: self.x + toBeAdded.x, y: self.y + toBeAdded.y)
}

func Minus(toBeMinused : NSPoint) -> NSPoint {
    return NSPoint(x: self.x - toBeMinused.x, y: self.y - toBeMinused.y)
}

static func fromScalar(scalar : Int) -> NSPoint {
    return NSPoint(x: scalar, y: scalar)
}
}

NSPoint初始值设定项取Int,所以我不知道为什么会是这样-有什么想法吗?

这看起来像是一个bug,是由
description
方法引起的 在
ToString()
方法中。相同的警告已在中出现

let x = CGFloat(12.0)
let s = x.description
作为一种解决方法,您可以改用字符串插值:

func ToString() -> String {
    return "(\(self.x),\(self.y))"
}
或者只是

func ToString() -> String {
    return "\(self)"
}
这给出了相同的结果