iOS本地推送设置周一到周五推周末不推怎么实现呢,用到的是本地推送不是服务端的推送
http://outofmemory.cn/code-snippet/2881/ios-bendi-tuisong-method
获取下今天是星期几,代码:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSInteger unitFlags = NSWeekCalendarUnit|NSWeekdayCalendarUnit;
NSDateComponents *comps = [calendar components:unitFlags fromDate:[NSDate dateWithTimeIntervalSinceNow:3600*24*7]];
int day = [comps weekday] ];
if(day==1 || day == 7){
//周末
}else {
//周一到周五。。
}
【周日,一。。。周六】= 【1.,2.。。7】
官方对weekday的解释:
Weekday units are the numbers 1 through n, where n is the number of days in the week. For example, in the Gregorian calendar, n is 7 and Sunday is represented by 1.
说的有不对的地方请指出来,哈哈