Objective-Cをちょっとやってみた

アプリ名はtest1。
とりあえず、ボタンを押してアラートを出す、っていう単純なアプリを作ってみた。
Objective-Cはてな記法シンタックスハイライトするには"objc"を挟めばいいらしい。
 

ソース

test1ViewController.h
@interface test1ViewController : UIViewController {
	IBOutlet UIButton *btn1;
}

-(IBAction)btn1_click;

 

test1ViewController.m

@endの前に追記。
1行が長すぎたから改行したけど、これは正しいんだろうか…?

-(IBAction)btn1_click {
	UIAlertView *alert = [
		[UIAlertView alloc]
		initWithTitle:@"Alert!"
		message:@"HelloWorld!!"
		delegate:self
		cancelButtonTitle:@"OK"
		otherButtonTitles: nil
	];
	[alert show];
	[alert release];
}

 
InterfaceBuilderを開いて、
Round Rect Buttonを追加。
アウトレット引っ張る。
アクション引っ張る。
 

参考URL

iPhoneアプリを作る流れ。
開発基礎トレ2:アウトレットとアクションの使い方|サルにもできるiPhoneアプリの作り方 Step2
http://ameblo.jp/micro-garden/entry-10322647497.html
 
↓アウトレット・アクションの考え方が解りやすい。
memo.393 » Blog Archive » [iPhone]Objective-Cの勉強メモ(ActionScriptとの比較的な):アウトレット・アクション
http://memo.393.bz/archives/1074
 
↓アラートの出し方。
[iphone]Alertメッセージの出し方 - applicott blog
http://applicott.blog63.fc2.com/blog-entry-60.html