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?
-
possible duplicate of What is the most efficient way in XCode to add a delegate's or protocol's methods to the .m file?Simon Whitaker– Simon Whitaker2011年09月13日 17:13:42 +00:00Commented Sep 13, 2011 at 17:13
-
Also see stackoverflow.com/questions/1694325/…Simon Whitaker– Simon Whitaker2011年09月13日 17:14:01 +00:00Commented Sep 13, 2011 at 17:14
1 Answer 1
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.