4

This seems like an obvious feature that should be there but i can't find it.

For example if my class is a uitableviewdelegate whats the quickest way for me to see all the available delegate methods and add the ones im interested in to my implementation file?

radiofrequency
  • 873
  • 8
  • 19
  • possible duplicate of [What is the most efficient way in XCode to add a delegate's or protocol's methods to the .m file?](http://stackoverflow.com/questions/1206500/what-is-the-most-efficient-way-in-xcode-to-add-a-delegates-or-protocols-methods) – Simon Whitaker Sep 13 '11 at 17:13
  • Also see http://stackoverflow.com/questions/1694325/xcode-possible-to-auto-create-stubs-for-methods-required-by-protocol-interface – Simon Whitaker Sep 13 '11 at 17:14

1 Answers1

2

You can use the tip in the first link that Simon posted above to get the method signatures for a delegate. After that, adding the code is up to you.

What I like to do is to choose the delegate methods that I most often use, and add them to a code snippet.

For example, for UITableViewDatasource I have a snippet called "UITableView Datasource Required Methods" containing:

- (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#> ;
}

Then I drag that snippet into my code whenever I'm creating a table delegate.

Community
  • 1
  • 1
sgress454
  • 24,870
  • 4
  • 74
  • 92