0

I am working on an app and I have this code:

NSDateFormatter *clockFormat = [[NSDateFormatter alloc]init];
[clockFormat setDateFormat:@"hh:mm a"];
self.clockLabel.text = [clockFormat stringFromDate:[NSDate date]];
[self performSelector:@selector(updateClockLabel) withObject:self afterDelay:1.0];

I created a view with subviews to create a LCD type clock display and I want to hide the correct subviews corresponding to the clockLabel. I created arrays of each view (digit), now how do I tell the views that if the first h in hh:mm is 1, hide these subviews to make an LCD "1" in the view.

Simply, how do I access each digit of hh:mm?

Boris R
  • 79
  • 1
  • 9
  • Please, look at answers: http://stackoverflow.com/questions/2927028/how-do-i-get-hour-and-minutes-from-nsdate http://stackoverflow.com/questions/12750626/get-total-hours-from-nsdate – pruinis Nov 24 '15 at 01:34

1 Answers1

0

You can use NSRange to get substrings. Use NSRangeMake(location,length). To get an NSString of the first character of self.clockLabel.text. You can say say

NSString *firstHourDigit = [self.clockLabel.text substringWithRange:NSRangeMake(0,1)];
beyowulf
  • 15,101
  • 2
  • 34
  • 40