草庐IT

nextRawValue

全部标签

swift - 是否可以从枚举方法内部更改枚举?

我在Swift中有一个枚举:enumOrientation:Int{caseRot_0=0,Rot_90,Rot_180,Rot_270我的枚举中的一个非静态方法旨在顺时针或逆时针移动方向:funcrotate(clockwise:Bool){varnextRawValue=self.rawValue+(clockwise?1:-1)ifnextRawValueOrientation.Rot_270.rawValue{nextRawValue=Orientation.Rot_0.rawValue}self=Orientation(rawValue:nextRawValue)}编译器告诉