我有一個NSMutableArray
和CGPoint
。當我嘗試將對象添加到我的CGPoint
可變我看到這個錯誤:從不兼容類型'id'指派給'CGPoint'(又名'struct CGPoint')
Assigning to 'CGPoint' (aka 'struct CGPoint') from incompatible type 'id'
這裏是我的代碼:
targetView.center = [arrayWithCoord objectAtIndex:1];
我試過的Xcode提示方式:
targetView.center = *((__bridge CGPoint *)([arrayWithCoord objectAtIndex:1]));
我也試試這個:
targetView.center = ((NSValue *)arrayWithCoord[0]).CGPointValue;
在所有情況下,我都有targetView.center = {0 , 0}
。我絕對相信這個數組不是空的。看我的NSLog
s:
2016-08-17 00:41:40.760 newword[16497:819894] Element NSPoint: {154.5, 31}
2016-08-17 00:41:40.760 newword[16497:819894] Element NSPoint: {197.5, 31}
2016-08-17 00:41:40.760 newword[16497:819894] Element NSPoint: {240.5, 31}
2016-08-17 00:41:40.761 newword[16497:819894] target center result {0, 0}
感謝您的幫助!
我的目標結果:2016-08-17 09:36:03.682新詞[17057:841214] P是{154.5,31} 2016-08-17 09:36:03.682新詞[17057:841214] target中心結果{0,0} –
我的目標中心未設置,請檢查target.center = CGPointMake(px,py); –