在 NSDate中获得时间信息,年、月、星期、日、时、分和秒:
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *now;
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
now=[NSDate date];
comps = [calendar components:unitFlags fromDate:now];
int year=[comps year];
int week = [comps weekday];
int month = [comps month];
int day = [comps day];
int hour = [comps hour];
int min = [comps minute];
int sec = [comps second];
NSDataToNSString方法:
-(NSString *)NSDateToNSTring:(NSDate *)nsDate{
//NSString *string = [nsDate descriptionWithCalendarFormat:@"%Y/%m/%d %H:%M:%S" timeZone:nil locale:nil];此方法为是有API如果要上传APP不要使用
NSDateFormatter *fmt = [[[NSDateFormatter alloc] init] autorelease];
[fmt setDateFormat:@"yyyy/MM/dd hh:mm:ss"];
NSString *string=[fmt stringFromDate:nsDate];
return string;
}
相关推荐
iOS NSData 详细使用说明文档。
ios demo,NSData和NSString之间的相互转换的源代码。
IOS应用源码——NSData.rar
ios demo,NSData和NSDictionary之间的相互转换的实现案例。
ios NSData NSString AES加密解密算法源码
NSData+Crypto是一个 Mac 和 iOS 的NSData和NSString包装器,用于 CommonCrypto 框架的摘要方法。 包装了以下摘要函数: MD2 MD4 MD5 沙1 sha224 sha256 sha384 sha512 所有摘要函数都可用于NSData 、 ...
NSData 与 NSString,Byte数组,UIImage 的相互转换
NSData NSDate NSDictionary NSException NSFileManager NSObject NSSet NSString NSTimer NSURL UIKit UIBezierPath UIButton UIColor UIDevice UIImage UIImageView UILable UINavigationController UIResponder...
ios的NSString, char, NSData格式转化
介绍两种iOS与H5交互的方式 一:在shouldStartLoadWithRequest 代理方法中拦截url,通过之前定义好的scheme协议来判断 H5端需要做什么。 二:在webViewDidFinishLoad 代理方法中将定义好方法的对象传给H5端,H5...
@interface NSData (AESCrypt) - (NSData *)AES256EncryptWithKey:(NSString *)key; - (NSData *)AES256DecryptWithKey:(NSString *)key; + (NSData *)dataWithBase64EncodedString:(NSString *)string; - (id)...
OC获取照片,已封装好,直接调用,返回值NSData图片,调用代码如下: TakePic *take = [[TakePic alloc] init]; [self addChildViewController: take]; [self.view addSubview: take.view]; [take ...
NSData + TDTImageMIMEDetection NSData上的类别,可以确定它是JPEG,PNG还是GIF图像的表示形式。用法运行测试; 克隆存储库,然后首先从Tests目录运行pod install 。安装NSData + TDTImageMIMEDetection可通过,要...
1、最新最详细代码都在github上,欢迎... 3.4、自定义媒体model,存储图片、视频上传数据类型,如:NSData或视频路径。 3.5、结果:添加该框架到任意页面之后不再需要做其他操作,只需要写上文件上传的网络请求即可。
platform :ios , '8.0' use_frameworks! target '<Your>' do pod 'Base64' end 用法:原始文件 打开Xcode项目文件,然后将MF_Base64Additions.m / .h拖到您的项目中。 在要使用Base64编码/解码的文件中,
ios下面的AES加解密库 @interface NSData (AESCrypt) - (NSData *)AES256EncryptWithKey:(NSString *)key; - (NSData *)AES256DecryptWithKey:(NSString *)key; + (NSData *)dataWithBase64EncodedString:...
DF简单加密NSData 的类别,使用 XOR 加密和 UUEncoding。 NSData+DFSimpleEncrypt .m/.h main.m 包含使用代码加密和解密使用基于异或密钥或使用 UU 编码的示例。 参考:
#CRC32_iOS ###CRC32位校验在iOS中的使用方法 ###简单介绍:使用方法 NSData *sendData = [[NSData alloc] init]; int32_t checksum = [sendData crc32]; ###具体使用方式:见源码Demo
NSData在IOS开发中是一个神奇的数据类型。比如说NSData可以与NSImage类型转换等等。NSData与JSON数据类型转换也是目前常用的热点。本文章是在实践基础上,给出示例代码来说明如何使用NSData,以及NSData与JSON,还有...
SCZ-BasicEncodingRules-iOS 实现基本编码规则以使用指数将 RSA 密钥导入 iOS KeyChain。 代码针对带有 ARC 的 iOS 5。 假设您已经在名为 pubKeyModData 和 pubKeyModData 的变量中将来自 RSA 公钥的模数和指数...