title: Conditional Number Percentage Styling iOS
body: <p>I'm trying to display a percentage label that will have some style based on its value.  A user gets likes and dislikes.  These totals are displayed in the totalLikesLabel and totalDislikesLabel.</p>
  
  <p>I want the approvalPercentageLabel to display the Percentage of likes to dislikes. Above 50% the text will show green, below 50% the text will show red.</p>
  
  <p>When I log the [self.totalLikesLabel.text intValue] and [self.totalDislikesLabel.text intValue] they appear as 22 and 12.  When they are both currently set to 1.</p>
  
  <p>@interface</p>
  
  <pre><code>@property (strong, nonatomic) IBOutlet UILabel *totalLikesLabel;
  @property (strong, nonatomic) IBOutlet UILabel *totalDislikesLabel;
  @property (strong, nonatomic) IBOutlet UILabel *approvalPercentageLabel;
  
  @property (nonatomic) int likeCount;
  @property (nonatomic) int dislikeCount;
  </code></pre>
  
  <p>-viewDidLoad</p>
  
  <pre><code>self.likeCount = [self.totalLikesLabel.text intValue];
  self.dislikeCount = [self.totalDislikesLabel.text intValue];
  
  float approvalPercentage = (self.likeCount / (self.likeCount + self.dislikeCount)) * 100.0;
  self.approvalPercentageLabel.text = [NSString stringWithFormat:@"%2.0f%%", approvalPercentage];
  </code></pre>
  
  <p>-helperMethod</p>
  
  <pre><code>//Create an Array to check either user photo
  NSArray *userPhotos = @[self.firstUserPhoto, self.secondUserPhoto];
  
  PFQuery *queryForLikes = [PFQuery queryWithClassName:kDDActivityClassKey];
  [queryForLikes whereKey:kDDActivityTypeKey equalTo:kDDActivityTypeLikeKey];
  [queryForLikes whereKey:kDDActivityFirstUserPhotoKey containedIn:userPhotos];
  [queryForLikes whereKey:kDDActivitySecondUserPhotoKey containedIn:userPhotos];
  [queryForLikes countObjectsInBackgroundWithBlock:^(int number, NSError *error) {
      self.totalLikesLabel.text = [NSString stringWithFormat:@"%i", number];
      NSLog(@"Likes %i", number);
  }];
  
  PFQuery *queryForDislikes = [PFQuery queryWithClassName:kDDActivityClassKey];
  [queryForDislikes whereKey:kDDActivityTypeKey equalTo:kDDActivityTypeDislikeKey];
  [queryForDislikes whereKey:kDDActivityFirstUserPhotoKey containedIn:userPhotos];
  [queryForDislikes whereKey:kDDActivitySecondUserPhotoKey containedIn:userPhotos];
  [queryForDislikes countObjectsInBackgroundWithBlock:^(int number, NSError *error) {
      self.totalDislikesLabel.text = [NSString stringWithFormat:@"%i", number];
      NSLog(@"Dislikes %i", number);
  }];
  </code></pre>