Jump to content

- - - - -

init of cells

  • Please log in to reply
1 reply to this topic

#1 ozie



  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169

Posted 20 April 2013 - 02:51 AM

seems there is a nice quick cellWithText to get a cell going

but sometime i find when building some tables there are lots of times i do
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 1",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 2",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 3",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 4",nil)]];
[section addCell:[SCTableViewCell cellWithText:NSLocalizedString(@"Support 5",nil)]];


sometimes these cells might have a detailLabel that needs text.. and sometime a little icon in the imageView

can we have some other inits for cells like

SCTableViewCell cellWithText: withDetailText: withImageViewImage:
that way we could do something like

[section addCell:[SCTableViewCell cellWithText:@"Title Text" withDetailText:nil withImageViewImage:[UIImage imageNamed:@"icon]]];

things like that

  • cometlinear likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.

#2 Tarek


    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452

Posted 29 April 2013 - 08:24 AM

Hi Greg,

Thank you very much for the suggestion, we'll definitely consider adding more initializers like these.

For the time being, you can also easily subclass SCTableViewCell to implement any initializer that you commonly use. For example:

@interface MyCell : SCTableViewCell

+ (id)cellWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *);
- (id)initWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *);


@implementation MyCell

+ (id)cellWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *)image
  return [[[self class] alloc] initWithText:text detailText:detailText imageViewImage:image];

- (id)initWithText:(NSString *)text detailText:(NSString *)detailText imageViewImage:(UIImage *)image
  self = [self initWithText:text];
    return nil;

  self.detailText = detailText;
  self.imageView.image = image;

  return self;


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users