2014-10-17 4 views
1

"프로토콜을 준수하지 않음"으로 실패한 swift (아래 참조) 구현에 다음 대리인을 사용하려고합니다. "후보자가 아닌 사람이 있습니다 일치 유형 (PieChartView) -> Int " 어떤 아이디어? 스위프트 Int는 C int로 변환 할 수 없기 때문에스위프트 : 후보가 일치하지 않음

@protocol PieChartViewDataSource <NSObject> 

@required 
- (int)numberOfSlicesInPieChartView:(PieChartView *)pieChartView; 
- (double)pieChartView:(PieChartView *)pieChartView valueForSliceAtIndex:(NSUInteger)index; 
- (UIColor *)pieChartView:(PieChartView *)pieChartView colorForSliceAtIndex:(NSUInteger)index; 

신속한 구현을

func numberOfSlicesInPieChartView(pieChartView: PieChartView) -> Int { 
    return 3 
} 

func pieChartView(pieChartView: PieChartView, colorForSliceAtIndex index: Int) -> UIColor? { 
    return UIColor(rgba: "#FF0000") 
} 

func pieChartView(pieChartView: PieChartView, valueForSliceAtIndex index: Int) -> Double { 
    return 100/3; 
} 
+0

사용중인 라이브러리 나 프로토콜 소스 선언에'PieChartViewDataSource'를 줄 수 있습니까? – Pintouch

답변

1
func numberOfSlicesInPieChartView(pieChartView: PieChartView) -> CInt { 
    return 32 
} 
func pieChartView(pieChartView: PieChartView, colorForSliceAtIndex index: UInt) -> UIColor { 
    return UIColor(red: 1.0, green: 0, blue: 0, alpha: 1) 
} 

func pieChartView(pieChartView: PieChartView, valueForSliceAtIndex index: UInt) -> Double { 
    return 100/3; 
} 

사용 -> CInt 대신 Int 실패. NSUInteger부호 때문에,>CDouble

사용 index: UInt 대신 index: Int-Double과 동일합니다.

+0

대단히 감사합니다! – sonix

관련 문제