• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

iPhoneに限った話ではないのですが。メモ:

via
http://discussions.apple.com/thread.jspa?messageID=8157595

CGRect → NSValue

CGRect rect = CGRectMake(x,y,w,h);
NSValue *rectValue = [NSValue valueWithCGRect:rect];

NSValue → CGRect

CGRect rect = [someNSValue CGRectValue];

posted by Png satoko on Wed 12 Aug 2009 at 22:18

調べてわかったのですが、複数パラメータを持つメソッドのSELは作成できるのですが(下記)、UIButtonなどのtarget-action設定時にパラメータを渡す事はできないようです。

-(void)methodWithNoArguments;
SEL noArgumentSelector = @selector(methodWithNoArguments);

-(void)methodWithOneArgument:(id)argument;
SEL oneArgumentSelector = @selector(methodWithOneArgument:); // notice the colon here

-(void)methodWIthTwoArguments:(id)argumentOne and:(id)argumentTwo;
SEL twoArgumentSelector = @selector(methodWithTwoArguments:and:); // notice the argument names are omitted

ちなみに、自分でSELのメソッドを呼び出すときには、パラメータを渡す事は可能:

-performSelector:
-performSelector:withObject:
-performSelector:withObject:withObject:

senderでごにょごにょ

できないと言っても、if(sender == _myButton) {} とか sender.tag をうまく使って、誰が呼出し元かや、intを渡す事は可能なようです。

Refs

posted by Png satoko on Wed 12 Aug 2009 at 20:51
Contents
[iPhone] 変換 CGRect <-> NSValue
[iPhone] UIButtonのtarget-action設定時、SEL/@selectorに複数パラメータを渡したい: できない
Comments
KingofSmack: Here also good reads for this mobile applicatio... '14-5
satoko: stackoverflowでも同じエラーを挙げている人がいたので、1.3でアップロードしたよっ... '10-12
ujihisa: :%s/blog/glob/g '10-7
satoko: しゅが〜様 返事が遅くなって申し訳ありません。また、投稿百景ご購入ありがとうございます。 ... '09-10
しゅが~: こんにちは。投稿百景を発売日翌日から利用しています。本当にいいAppを作っていただきました。罫... '09-10
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ