ios - Detect If between time periods -
I'm having trouble with the code given below. What's the problem with it? I have tried to define the NSUInteger as
int , but it still does not work.
NSCalendar * cal = [NSCalendar currentCalendar]; NSDateComponents * Component = [KAL component: NSHourCalendarUnitDate: now longer]; NSLog (@ "% LD", [hours of components]); NSUInteger * timeHour = [component hours]; If it is between 5 and 9 in the morning for the code, then it can be ascertained that
. >
Anything that is timeHour & lt; 5 Automatically timeHour> 9 . You are desirous of these two situations, which can never be true at the same time, so you will always make a wrong return.
In addition, if is nothing in the block
if (timeout => 5 & amp; amp; Time holes & lt; = 9) {// stuff}
timeHour> = 5 gives the right for anything where is greater than
Time gives the right for anything where timeHour is 9 or less.
another amp; Amp; Both and b are correct.
Edit: Also ... NSUInteger * timeHour = [components hour];
There is a problem in this line that I have caught. You are defining timeHour as the NSUInteger POINTER as NSUInteger . Get rid of * and try again.
Comments
Post a Comment