2013-09-30 66 views
1

這段代碼在X-代碼4.6工作,但無法在X-代碼5:多種方法命名不匹配的結果,參數類型發現或「邊緣」屬性

NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity:4]; 

for (int k=0; k<4; k++) { 
    int e = arc4random_uniform(3)+1; 

    if (arc4random_uniform(2)>0) { 
     e *= -1; 
    } 

    [a addObject:[NSNumber numberWithInt:e]]; 
} 

if (i>0) { 
    int l = [arrayPieces count]-pieceNumber; 
    int e = [[[[arrayPieces objectAtIndex:l] edges] objectAtIndex:1] intValue]; //CAUSES ERROR 
    [a replaceObjectAtIndex:3 withObject:[NSNumber numberWithInt:-e]]; 
} 

if (j>0) { 
    int e = [[[[arrayPieces lastObject] edges] objectAtIndex:2] intValue];//CAUSES ERROR 
    [a replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:-e]]; 
} 

我也得到相關的以下錯誤同樣的代碼:

壞接收器類型「UIRectEdge」(又名「枚舉UIRectEdge」)

...但我有我的項目中沒有提及「UIRectEdge」。

我已經搜索了類似的這些錯誤的案例,但沒有什麼東西似乎足以解決我能夠嘗試的問題。

任何幫助將不勝感激。

謝謝。

回答

1

'邊緣'屬性返回一個UIRectEdge。如果您有裏面有它自己的getter稱爲「邊緣」 arrayPieces「自定義類,嘗試鑄造對象是這樣的:

int e = [[[((MYCUSTOMOBJECT*)[arrayPieces objectAtIndex:l]) edges] objectAtIndex:1] intValue]; //CAUSES ERROR 
0

替換爲以下內容分配給e

int e = [[[((PieceView *)[arrayPieces objectAtIndex:l]) edges] objectAtIndex:1] intValue]; 
相關問題