字典转为Json字符串
//字典转为Json字符串
+(NSString *)dictionaryToJson:(NSDictionary *)dic
{
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&error];
re
turn [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
iOS_隐藏顶部状态栏方式
Storyboard
界面上选中UIViewController,最右边Simulated Metrics找到 Status Bar 设定成 None
ViewController
iOS 6通过[UIApplication sharedApplication] 取得app的单例,然后调用setStatusBarHidden方法隐藏 Status Bar。
生成 n 位随机数
NSString *string = [[NSString alloc]init];
for (int i = 0; i < 32; i++) {
int number = arc4random() % 36;
if (number < 10) {
int figure = arc4random() % 10;
NSString *tempString = [NSString stringWithFormat:@"%d", figure];
string = [string stringByAppendingString:tempString];
}else {
int figure = (arc4random() % 26) + 97;
char character = figure;
NSString *tempString = [NSString stringWithFormat:@"%c", character];
string = [string stringByAppendingString:tempString];
}
}
NSLog(@"%@", string);
获取 UDID
NSString *_String = [[NSUUID UUID] UUIDString];//随机字符串
NSLog(@"%@",_String);
大数据存储单位介绍(TB、PB、EB、ZB、YB有多大)
Byte字节,计算机信息的一种基本单位,也就是信息的存储单元。
1Byte = 8 Bit
1 KB = 1,024 Bytes
1 MB = 1,024 KB = 1,048,576 Bytes
1 GB = 1,024 MB = 1,048,576 KB = 1,073,741,824 Bytes
1 TB = 1,024 GB = 1,048,576 MB = 1,073,741,824 KB = 1,099,511,627,776 Bytes
1 PB = 1,024 TB = 1,048,576 GB =1,125,899,906,842,624 Bytes
1 EB = 1,024 PB = 1,048,576 TB = 1,152,921,504,606,846,976 Bytes
1 ZB = 1,024 EB = 1,180,591,620,717,411,303,424 Bytes
1 YB = 1,024 ZB = 1,208,925,819,614,629,174,706,176 Bytes
XCode调试技巧之EXC_BAD_ACCESS中BUG解决
1、通过编辑Edit Scheme,选择Diagnostics,勾选Enable Zombie Objects & Malloc Stack(注意、调试完毕后必须取消勾选,因为Zombile模式不会释放内存,很危险)
2、重新run你的程序,reproduce crash流程,控制台会输出如下log:
iOS断言 NSAssert的使用
在程序设计中,断言(assertion)是一种放在程序中的一阶逻辑(如一个结果为真或是假的逻辑判断式),
目的是为了标示与验证程序开发者预期的结果-当程序运行到断言的位置时,对应的断言应该为真。若断言不为真时,程序会中止运行,并给出错误消息。