Xcode Code Snippets
Every time I tried to setup a UITableView I got frustrated with writing all the table view delegates, so after eons of doing this I finally discovered Code Snippets in Xcode.
- Write some code in Xcode,
- select the desired part of the code,
- drag and drop it into the Code Snippets Library,
- to reuse the code, simply drag it to your project from the library.
Here is my snippet for UITableView delegates:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return <#number of sections#>
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return <#number of rows in section#>
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return <#row height#>
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellIdentifier = @"CellIdentifier";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = @"";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
Written by galex
Related protips
3 Responses
neat!
over 1 year ago
·
The is a much better way to manage code snippets in Xcode. It is Snippets http://snippets.me/. Check out this demo http://www.youtube.com/watch?v=0qzsVhKqOHw
over 1 year ago
·
its great !!! it will save but time . but sorry to say it will make my programming skill passive.
but definitely will use for making my programming cool...
thanks
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xcode
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#