xcode가 xcode에서 아래 첨자를 호출하려고 시도하는 이유를 이해할 수 없습니다. xcode에서 원하지 않습니다.Xcode6 'subscript'를 호출 할 수 없습니다.
struct Point3D
{
var x: Double = 0.0
var y: Double = 0.0
var z: Double = 0.0
init(x:Double, y:Double, z:Double) {self.x = x; self.y = y; self.z = z}
}
코드에서 작동하지 않습니다 그러나, 그것은 말한다 : Cannot invoke 'subscript' with an argument list of type '(x: Double, y: Double, z: Double)'
private func convertFileStringToPoint3D(str:String)->Point3D
{
let components_file_string_point3d = str.componentsSeparatedByCharactersInSet(NSCharacterSet(charactersInString: " \t"))
if components_file_string_point3d.count>2 {
return Point3D(x: Double(components_file_string_point3d[0]), y: Double(components_file_string_point3d[1]), z: Double(components_file_string_point3d[2]))
} else {
assertionFailure("Wrong File Structure. Cannot convert string to Point3D.")
}
}
을 이러한 유형과 초기화를 그리고 나는 그것이있는 doubleValue라는 멤버를 가지고 있지 않았다고 말한다는 NSString의있는 doubleValue를 사용하려고하면 ...
나는 두렵다. (나는 방금 doubleValue 대신에 한 글자 doublevalue를 놓쳤다 ... 이것은 중복 되었으니 삭제 해 주시길 바랍니다. 아무런 질문이 없으니 실수는 아님. ...
문제는 Point3D 클래스의 init 때문이 아닙니다. Double에는 String을 사용하는 init이 없기 때문입니다. –
http://stackoverflow.com/questions/24031621/swift-how-to-convert-string-to-double ... –
typechecker에게 당신이 바로 여기 있다고 확신 시키십시오. let components_file_string_point3d : [NSString]' , 그리고 나서'doubleValue'를 호출하십시오 – CodaFi