2011-09-13 4 views
4

これは明白な機能のようですが、私はそれを見つけることができません。xcode 4にすべてのデリゲート関数をリストし、自動的にコードスニペットをファイルに追加する方法はありますか?

たとえば、私のクラスがuitableviewdelegateの場合、利用可能なすべてのデリゲートメソッドを見て、自分のインプリメンテーションファイルに興味のあるものを追加する最も簡単な方法は何ですか?

+0

可能性のある複製[.mファイルに代理人またはプロトコルのメソッドを追加するためのXCodeで最も効率的な方法は何ですか?](http://stackoverflow.com/questions/1206500/what-is-themost-効率的なやり方でのxcode-to-delegate-or-protocols-methodsの追加) –

+0

http://stackoverflow.com/questions/1694325/xcode-possible-to-auto-create-stubs-forも参照してください。 -methods-required-by-protocol-interface –

答えて

2

Simonが上に掲載した最初のリンクのヒントを使用して、デリゲートのメソッドシグネチャを取得できます。その後、コードを追加するのはあなた次第です。

私は何をしたいことは、私が最も頻繁に使用するデリゲートメソッドを選択することである、と私は含む「のUITableViewデータソースに必要なメソッド」と呼ばれるスニペットを持ってUITableViewDatasourceため例えばadd them to a code snippet.

、:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellIdentifier = @"myCellName"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease]; 
    } 

    //customize cell before showing it 

    return cell; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return <#numRow#> ; 
} 

次に、テーブルデリゲートを作成するたびに、そのコードをコードにドラッグします。

関連する問題