positionについて調べる – 解決編

公開日: : 最終更新日:2013/11/12 cocoa

記事内に広告を含む場合があります。記事内で紹介する商品を購入することで、当サイトに売り上げの一部が還元されることがあります。

以下、macosx-dev MLでのやり取り。


Hi Guys,

I wrote the following programs.

-(void)changeSelectedIndex:(NSInteger)theSelectedIndex
{
selectedIndex=theSelectedIndex;

if (selectedIndex == [names count]) selectedIndex=[names count]-1;
if (selectedIndex < 0) selectedIndex=0;

selectionLayer.position = [[[menusLayer sublayers]
objectAtIndex:selectedIndex] position];
};

When I Bild it, the following errors are output.

/Users/user/Desktop/CoreAnimationMenu/MenuView.m:160: warning:
multiple methods named '-position' found
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSScriptObjectSpecifiers.h:191:
warning: using '-(NSInsertionPosition)position'
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h:598:
warning: also found '-(CGPoint)position'
/Users/user/Desktop/CoreAnimationMenu/MenuView.m:160: error:
incompatible type for argument 1 of 'setPosition:'
/Users/user/Desktop/CoreAnimationMenu/MenuView.m:160: warning:
multiple methods named '-position' found
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSScriptObjectSpecifiers.h:191:
warning: using '-(NSInsertionPosition)position'
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h:598:
warning: also found '-(CGPoint)position'
/Users/user/Desktop/CoreAnimationMenu/MenuView.m:160: error:
incompatible type for argument 1 of 'setPosition:'

I appreciate any help.


akio

As the warnings say: there are several position accessors in the frameworks, and the compiler does not know which one to use. To avoid this warning you should type the selectionLayer, as in [(CALayer)[[menusLayer sublayers] objectAtIndex:selectedIndex] position]

Christiaan

I corrected the code as follows.

selectionLayer.position = [
(CALayer*)[[menusLayer sublayers]
objectAtIndex:selectedIndex] position];

Warning was not displayed.

Tyank you very mach.

なるほど、[]内でC++みたいにキャストしたりできるのか。

関連記事

サンフランシスコのピア39にあるチャウダーズでクラムチャウダーを食す!

lolipop アップルの開発者向けイベント「WWDC2014」

ミスドのカルピスドーナツとカルピスポンデリングを食べてみた!

ミスドで期間限定のカルピスコラボ商品「カルピスドーナツ」と「カルピ

十三カレー計画で牛すじカレーネギのせを食す!(大阪・十三)

「iPhoneアプリ開発キャンプ@大阪」のランチで、十三カレー計画

大阪・難波の加寿屋 法善寺でかすうどんを食す。ランチタイムはおにぎり2個まで無料!

大阪・難波の加寿屋 法善寺 (かすうどん KASUYA)で、かす

ライブドアブログで運営していた「あきお商店」を「卵は世界である」に改名しました

少し前からライブドアブログで「あきお商店」というブログをやって

→もっと見る

PAGE TOP ↑