2014-06-13 4 views
1

아래의 내 복식을 위해 내가하는 것처럼 객관적인 목표를 달성하는 것이 정말로 필요한가? 놀이터에서이 단계없이 작동하지만 보통의 신속한 파일에서는 컴파일되지 않습니다.float를 신속하게 ObjectiveC에 연결해야합니까?

더 깨끗한 방법이 있습니까?

var prevX = 0.0 
    var prevY = 0.0 
    var count = 0 

    for item : AnyObject in myGraph.vertices { 
     count++ 
     if let v = item as? Vertex { 

      x = Double(x) 
      y = Double(y) 

      x = x - width/2.0 
      y = y - width/2.0 
      //var fwidth = Float(width) 

      var rect = CGRect() 
      rect.origin.x = x.bridgeToObjectiveC().floatValue 
      rect.origin.y = y.bridgeToObjectiveC().floatValue 
      rect.size.width = width.bridgeToObjectiveC().floatValue 
      rect.size.height = rect.size.width 
+1

https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_416 –

+0

는 관련이있는 것으로 나타남 대상이 64 비트인지 32 비트인지 여부 –

+0

두 배는 64 비트 숫자이며, 항상 발생했습니다. 플로트는 32 비트 숫자이며, 항상 사용되었습니다. http://en.wikipedia.org/wiki/Double-precision_floating-point_format 및 http://en.wikipedia.org/wiki/Single-precision_floating-point_format –

답변

2

아니, 당신은 그것을

rect.origin.x = Float(x) 
rect.origin.y = Float(y) 
rect.size.width = Float(width) 
rect.size.height = rect.size.width 

N.B.을 할 수있는 부동 소수점 생성자를 사용할 수 있습니다 나는 이것에 대해 애플에게 버그 보고서를 열었다. 최소한 행동은 일치해야합니다.