Skip to content

Instantly share code, notes, and snippets.

@blork
Created January 18, 2012 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blork/1634862 to your computer and use it in GitHub Desktop.
Save blork/1634862 to your computer and use it in GitHub Desktop.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *StoreCellIdentifier = @"StoreCellIdentifier";
static BOOL nibsRegistered = NO;
if (!nibsRegistered) {
UINib *nib = [UINib nibWithNibName:@"StoreLocationCell" bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:StoreCellIdentifier];
nibsRegistered = YES;
}
StoreLocationCell *cell = [tableView dequeueReusableCellWithIdentifier: StoreCellIdentifier];
// Configure the cell...
if (storeLocations != nil) {
Store_location *sl = [storeLocations objectAtIndex:[indexPath row]];
cell.name = sl.address_city;
cell.address = sl.fullAddress;
cell.pinImage = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png", [indexPath row]]];
}
return cell;
}
-----------
//
// StoreLocationCell.m
// Look Book
//
// Created by Sam Oakley on 18/01/2012.
// Copyright (c) 2012 Luke Stringer & Sam Oakley. All rights reserved.
//
#import "StoreLocationCell.h"
@implementation StoreLocationCell
@synthesize name, nameLabel;
@synthesize address, addressLabel;
@synthesize pinImage, pinImageView;
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setName:(NSString *)n {
if (![n isEqualToString:name]) {
name = [n copy];
nameLabel.text = name;
}
}
- (void)setAddress:(NSString *)a {
if (![a isEqualToString:address]) {
address = [a copy];
addressLabel.text = address;
}
}
- (void)setPinImage:(UIImage *)pi {
if (![pi isEqual:pinImage]) {
pinImage = [pi copy];
pinImageView.image = pinImage;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment