2017年03月11日
如果需要每个属性或每个方法都去指定 nonnull 和 nullable ,将是一件非常繁琐的事。苹果为了减轻我们的工作量,专门提供了两个宏: NS_ASSUME_NONNULL_BEGIN 和 NS_ASSUME_NONNULL_END 。在这两个宏之间的代码,所有简单指针对象都被假定为 nonnull ,因此我们只需要去指定那些 nullable 指针对象即可。如下代码所示
2017年03月11日
最近工作上需要获取设备的一些信息,整理了一下,方便大家。1.获取电池电量(一般用百分数表示,大家自行处理就好)-(CGFloat)getBatteryQuantity
{
return [[UIDevice currentDevice] batteryLevel];
}2.获取电池状态(UIDeviceBatteryState为枚举类型)-(UIDeviceBatt
2017年03月10日
最近在开发一个大项目的时候遇到一个很头疼的问题,由于项目代码较多,每次都要编译链接1分钟左右,调试的时候很浪费时间,于是研究了一下如何提高编译链接的速度,在这里分享给大家。提升编译链接的速度主要有以下三个方式:1. 提高XCode编译时使用的线程数defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 4XCode默认使用与CPU核数相同的线程来进行编译,但由于编译过程中的IO操作往往
2017年03月06日
Command /usr/bin/ditto failed with exit code 1For Mac OS Sierra, this work for me:cd /Users/YOUR_USER_NAME/Library/Developer/Xcode/DerivedDatathenxattr -dr com.apple.FinderInfo *and then rebuild your project..and fix the err
2017年03月02日
let mySet: Set = ["a", "b", "c", "d"]
mySet[advance(mySet.startIndex, 2)] // -> something from the setAs of Xcode7 beta6/Swift2.0:let&
2017年02月23日
RunLoop是一种事件处理循环机制,类似于中断处理,它可以监听一个或多个定时器源(Timer Sources)和输入源(Input
Sources),当没有事件时,它让线程休眠;当有事件发生时,系统唤醒线程,把事件放入RunLoop队列,RunLoop再分发给用户指定的事件处理入口函数。由此可以看出,RunLoop是为了低功耗而设计的,它不会浪费CPU的时间,不会阻止CPU进入低功耗模式,对于对功耗敏感的移动终端来说,在恰当的场合使用它能让你的程序获得更好的性能。RunLoop我们可以通过
2017年02月15日
self.captureSession = [[AVCaptureSession alloc] init];
NSError *error;
// Set camera capture device to default and
2017年02月15日
@implementation UIImage (QR)
+ (UIImage *)qrImageForString:(NSString *)string imageSize:(CGFloat)Imagesize {
CIFilter *filter = [CIFilte
2017年02月15日
这写头文件是用于获取ip等系列功能的#include <arpa/inet.h>#include <netdb.h>
#include <net/if.h>
#include <ifaddrs.h>#import <dlfcn.h>
#import <SystemConfiguration/SystemConfiguration.h> 获
2017年02月09日
struct tKeyMapping
{
const char * obfuscatedKey;
const char * key;
};
static const struct tKeyMapping&n