2016-08-16 4 views
1

에서 나는 몇 가지 핵심 그래픽 구조, 즉 CGSize 및 CGRect에 대한 스위프트의 일부 확장 이곳CGRect와 CGSize 확장 볼 수 없다 오브젝티브 C

enum Orientation { 
     case Portrait 
     case Landscape 
     case Square 
    } 


extension CGSize { 

    /// Based on the size's dimensions, what orientation is it 
    var orientation: Orientation { 

     if width > height { 
      return .Landscape 
     } else if height > width { 
      return .Portrait 
     } else { 
      return .Square 
     } 
    } 

} 

.... CGSize 하나의 모습입니다 Objective-C 클래스에서 이들을 사용해야합니다. Swift 헤더를이 클래스로 가져 왔으며 Swift에서 작성한 다른 확장이이 클래스에서 작동합니다. 그러나이 둘은 보이지 않습니다. 나는 이것이 클래스에 대한 확장이 아니기 때문에 그것을 추측하고 있습니다. Objective-C 코드로 작업 할 수있는 방법이 있습니까?

답변

1

사실 OrientationCGSize은 수업이 아니기 때문에 불가능합니다. Orientationenum이고 CGSizestruct입니다.

documentation에 따르면 Objective-C에서는 이러한 신속한 기능인 Enumerations defined in Swift without Int raw value typeStructures defined in Swift을 사용할 수 없습니다.