Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed badgeText to badgeNumber

  • Loading branch information...
commit 1b46cedda352848429659a24862812109a75de98 1 parent c7a2834
Yonat Sharon authored
2  BadgeView/BadgeTableViewCell.h
@@ -12,6 +12,6 @@
12 12 @interface BadgeTableViewCell : UITableViewCell
13 13
14 14 @property (strong, nonatomic) BadgeLabel *badge;
15   -@property (weak, nonatomic) NSString *badgeText;
  15 +@property (nonatomic) NSInteger badgeNumber; // for convenience
16 16
17 17 @end
12 BadgeView/BadgeTableViewCell.m
@@ -30,17 +30,17 @@ - (void)createBadge
30 30 [self.contentView addSubview:badge];
31 31 }
32 32
33   -- (NSString *)badgeText
  33 +- (NSInteger)badgeNumber
34 34 {
35 35 if (self.badge) {
36   - return self.badge.text;
  36 + return [self.badge.text integerValue];
37 37 }
38   - return nil;
  38 + return 0;
39 39 }
40 40
41   -- (void)setBadgeText:(NSString *)badgeText
  41 +- (void)setBadgeNumber:(NSInteger)badgeNumber
42 42 {
43   - if ([badgeText length] == 0) {
  43 + if (badgeNumber == 0) {
44 44 badge.hidden = YES;
45 45 return;
46 46 }
@@ -49,7 +49,7 @@ - (void)setBadgeText:(NSString *)badgeText
49 49 [self createBadge];
50 50 }
51 51
52   - badge.text = badgeText;
  52 + badge.text = [NSString stringWithFormat:@"%d", badgeNumber];
53 53 badge.hidden = NO;
54 54 [self layoutBadge];
55 55 }
2  BadgeView/ViewController.m
@@ -52,7 +52,7 @@ - (void)initCells
52 52 for (int i = 0; i < 3; ++i) {
53 53 cell = [[BadgeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
54 54 cell.textLabel.text = [NSString stringWithFormat:@"Cell %d", i];
55   - cell.badgeText = [NSString stringWithFormat:@"%d", lround( pow(7, 1+i) )];
  55 + cell.badgeNumber = lround( pow(7, 1+i) );
56 56 [cells addObject:cell];
57 57 }
58 58 }

0 comments on commit 1b46ced

Please sign in to comment.
Something went wrong with that request. Please try again.