判断是否为模拟器
#define isSimulator (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location) if (isSimulator) { if ([[UIScreen mainScreen] bounds].size.height > 700) { core.device = 2; }else{ core.device = 4; } }
tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect); //上分割线, CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width, 1)); //下分割线 CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); CGContextStrokeRect(context, CGRectMake(5, rect.size.height-1, rect.size.width , 1)); }
//使用系统自带的函数把json格式的字符串转换成 NSDictionary 然后再依次解析 NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&jsonParseError];
NSString
NSString *test = @"111111" @"2222”; test == 1111112222
http://code4app.com/ios/Spotlight-like-Hint-View/4f9cba5106f6e7a71f000004
oc 反射
int i; int propertyCount = 0; objc_property_t *propertyList = class_copyPropertyList([/*NSMutableArray*/** class], &propertyCount); for ( i=0; i < propertyCount; i++ ) { objc_property_t *thisProperty = propertyList + i; const char* propertyName = property_getName(*thisProperty); NSLog(@"Person has a property: ‘%s‘", propertyName); }
方法省略参数
@interface NSMutableArray (variadicMethodExample) - (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects. @end @implementation NSMutableArray (variadicMethodExample) - (void) appendObjects:(id) firstObject, ... { id eachObject; va_list argumentList; if (firstObject) // The first argument isn‘t part of the varargs list, { // so we‘ll handle it separately. [self addObject: firstObject]; va_start(argumentList, firstObject); // Start scanning for arguments after firstObject. while (eachObject = va_arg(argumentList, id)) // As many times as we can get an argument of type "id" [self addObject: eachObject]; // that isn‘t nil, add it to self‘s contents. va_end(argumentList); } } @end
显示完整的访问路径 defaults write com.apple.finder _FXShowPosixPathInTitle -bool TRUE;killall Finder 恢复默认状态 defaults delete com.apple.finder _FXShowPosixPathInTitle;killall Finder 输入想要去的文件夹路径 按键盘 Command + Shift + G LAST SHUTDOWN
+ (instancetype)shareDb { static STDbHandle *stdb; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ stdb = [[STDbHandle alloc] init]; }); return stdb; }
Xcode文档代码注释工具vvDocumenter 插件下载:https://github.com/onevcat/VVDocumenter-Xcode 安装:运行下载的vvDocumenter工程,重启Xcode 使用:方法前面输入///,自动生成注释框架,修改对应说明
1 | [titleLabel resizeLabelByContent]; |
1. 试了Hide during application launch的勾选选项,不可以
2. 试了ViewController中用函数,还是不可以
1 2 3 4 |
- (BOOL)prefersStatusBarHidden { return YES;//隐藏为YES,显示为NO } |
1 2 |
// 显示状态栏 [[UIApplication sharedApplication] setStatusBarHidden:FALSE]; |
xcode用Tab建立了多个子界面
操作方式:option+shift,然后点击要打开的文件,会出现以下选项~
NSRecursiveLock
NSRecursiveLock类定义的锁可以在同一线程多次获得,而不会造成死锁。
一个递归锁会跟踪它被多少次成功获得了。每次成功的获得该锁都必须平衡调用锁住和解锁的操作。只有所有的锁住和解锁操作都平衡的时候,锁才真正被释放给其他线程获得。
NSFileManager
contents 内容
create 创建
remove 移动
copy 复制
handler 处理者
exists 存在
readable
writable
attributes
保存图片
- (void)downloadImageWithURL:(NSString *)url toSavePath:(NSString *)toSavePath{ NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; UIImage *image = [UIImage imageWithData:imageData]; if (image != nil) { [UIImagePNGRepresentation(image)writeToFile:toSavePath atomically:YES]; } }
http://www.w3school.com.cn/sql/sql_distinct.asp
原文:http://blog.csdn.net/ydc__/article/details/25804915