【代码笔记】iOS-两个时间字符串的比较
2016-04-21 09:30
495 查看
一,效果图。
二,代码。
二,代码。
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initTimerCompare]; } #pragma -mark -functions //比较时间 -(void)initTimerCompare { NSString *starTimer=@"2014-08-29"; NSString *finishTimer=@"2014-09-30"; BOOL result = [starTimer compare:finishTimer] == NSOrderedSame; NSLog(@"result:%d",result); if (result==1) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间和结束时间相等" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil]; [alert show]; return; } BOOL result1 = [starTimer compare:finishTimer]==NSOrderedDescending; NSLog(@"result1:%d",result1); if (result1==1) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间晚于结束时间" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil]; [alert show]; return; } BOOL result2 = [starTimer compare:finishTimer]==NSOrderedAscending; NSLog(@"result2:%d",result1); if (result2==1) { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"开始时间早于结束时间" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil]; [alert show]; return; } }
相关文章推荐
- JS 与 iOS 交互
- iOS上传图片
- 关于用boundingRectWithSize计算label自适应高度那点事
- iOS 下拉列表
- iOS里加密字符串、图片、视频方法
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- Cordova - 使用Cordova开发iOS应用实战5(获取手机里照片,并编辑)
- 使用Xcode和Instruments调试解决iOS内存泄露
- Nagios 监控系列学习 ―― 简介和安装
- iOS应用性能调优的25个建议和技巧
- IOS学习之——用NSUserDefaults保存和读取程序设置
- IOS常用的页面传值方式
- iOS CGAffineTransform简单应用
- CodingNet - Learning - 1
- CodingNet - Learning - 0
- CoreAnimation
- 最火开源iOS游戏汇总
- iOS关于系统键盘的长度限制
- ios开发,javascript直接调用oc代码而非通过改变url回调方式
- iOS 【const的使用】