xib、VC
KFViewController *kfViewCtl = [[KFViewController alloc] initWithNibName:@"KFViewController" bundle:nil];
weak strong 关键字
//weak关键字声明的属性,很可能会在某个地方就被释放了,所以如果不希望它被释放的时候要用strong关键字
This application's application-identifier entitlement does not match
This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed.
iPhone上已经装了包标识符一样的 App,删掉再运行。//http://www.jianshu.com/p/b10680a32d35
svn 管理软件 上传.a文件,cornerstone versions
在Versions中手动添加文件
选择Versions的菜单View-->Show Ignored Items,这样就会显示出ignored的文件,找到你要上传的.a文件,右键“Add”就可以了。
不知道是不是versions的问题,以后试下cons看看会不会有这个问题。
http://blog.csdn.net/itianyi/article/details/39401017 http://www.jianshu.com/p/6d2bfbc39de7 xcode制作framework 这时候我们可以新建一个工程然后将framework拖进去就直接可以用了。但是事情并没有结束,如果我们尝试在真机中跑的话,会出现错误。因为我们编译的时候用的是模拟器,他是X86_64架构的,而真机是arm架构的,自然会出现错误,这里我们可以想到可以用真机再build一次那不就可以了嘛,确实可以,但是我们每次build都需要跑两次,噢不止两次,现在Apple的cpu架构如下
arm7: 在最老的支持iOS7的设备上使用
arm7s: 在iPhone5和5C上使用
arm64: 运行于iPhone5S的64位 ARM 处理器 上
i386: 32位模拟器上使用
x86_64: 64为模拟器上使用
build完了还需要通过lipo命令把他们合起来,实在是非常麻烦。这时候就需要写一个脚本来自动化实现这个过程。
文/HarriesChen(简书作者)
原文链接:http://www.jianshu.com/p/6d2bfbc39de7
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
storyboard 代码跳转
// 获取指定的Storyboard,name填写Storyboard的文件名
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// 从Storyboard上按照identifier获取指定的界面(VC),identifier必须是唯一的
DeviceManagerVC *receive = [storyboard instantiateViewControllerWithIdentifier:@"DeviceManagerVC"];
[self.navigationController pushViewController:receive animated:YES];
sql语句
select * from DidDownTable order by id desc limit1//取最后那一条
select * from DidDownTable order by id limit 1//取第一条
FMResultSet *rs = [[SingleTonManager sharedInstance].db executeQuery:@"SELECT * FROM UserData WHERE Month = ? or Month = ? and Day >= ? or Day <= ?",[NSNumber numberWithInt:MonthValue],[NSNumber numberWithInt:EndMonthValue],[NSNumber numberWithInt:DayValue],[NSNumber numberWithInt:EndDayValue]]; FMResultSet *rs2 = [[SingleTonManager sharedInstance].db executeQuery:@"SELECT * FROM UserData WHERE Year = ? And Month = ? and Day = ? and TimeIndex <= ?",[NSNumber numberWithInt:YearValue],[NSNumber numberWithInt:MonthValue],[NSNumber numberWithInt:DayValue],[NSNumber numberWithInt:31]]; ///////// select * from DidDownTable order byid desc limit 1//取最后那一条
select * from DidDownTable order by id limit1//取第一条////http://www.cnblogs.com/wengzilin/archive/2012/03/27/2419851.html
select count(*) from film;取得数据库里总共有多少条数据
FMResultSet *rs = [[SingleTonManager sharedInstance].db executeQuery:@"select * from UserData where BraceletName like ? order by user_id desc limit 1",PeripheralName];//获取指定一个字段为某个值的一组数据中,最后一条数据////搜索:sql多条件查询语句,会出现很多文章
readValueForCharacteristic与setNotifyValue的关系
http://www.coderyi.com/archives/137
readValueForCharacteristic
setNotifyValue:YES forCharacteristic:
no such file or directory: '.m'
clang: error: no input files解决办法
no such file or directory: '.m'
clang: error: no input files The problem might be because your project > target > Build Phases > Compile Sources is trying to compile a file that doesn't exist. It might be in there twice, like the below screen shot. My project contains UIImage+FFXtras, I can even remove it and re-add it and this won't resolve the problem! http://stackoverflow.com/questions/11352507/im-getting-clang-error-no-input-files
cell自定义的底部线部分消失的原因
如果使用了cell本身的textlabel,那么你自己拖的cell底部的线,很可能被遮挡住,从而使线看起来缺失,解决办法是不使用textlabel,自己再拖一个label
Mac建整套SVN
mac终端搭建服务器,mac下载cornerstone建仓,关联开发者mac下载cornerstone,就可以实现svn功能
头文件的属性外部可以吊用,实现文件的生命属性外部无法调用
.a文件不能再svn中提交
mac环境下svn的使用
file:///Users/hope/Downloads/Mac环境下svn的使用%20-%20M了个J%20-%20博客频道%20-%20CSDN.NET.webarchive
如果要更新,即update,那记得先复制一份源代码再更新,如果大家更新后,有问题可以使用svn恢复到以前的某一个版本 如果两个人同时修改了storyboard,但是是不同的文件,是不会引起冲突的///cornerstone里面,有时会出现.DS_store文件,后面会有一个灰色的I,这是忽略文件,选中cornerstone文件,然后点击mac顶上状态栏的view,在弹出的菜单中选择 hide ignored items,就可以让他消失在cornerstone中,但是如果要显示.a,就要选择show ignored items。
info.plist 提交冲突
info.plist在cornerstone更新后,报冲突,解决办法在xcode中选择info.plist然后右键,open as >sourse code,就可以修改有问题的东西
GCD延迟指定的时间执行block里面的代码
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
});
GCD开子线程,并返回主线程
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// 执⾏耗时的异步操作...
dispatch_async(dispatch_get_main_queue(), ^{
// 回到主线程,执⾏UI刷新操作
LOG(@"==== %d ==== %@",[NSThread isMainThread],@"数据已全部存进数据库");
});
});
could not find any information for the class named
iOS could not find any information for the class named
解决的博客
http://www.cnblogs.com/DengfengZhang/p/5345010.html
cocoapods安装使用教程
http://blog.csdn.net/showhilllee/article/details/38398119/
CBPeripheral的uuid
同一个外设的uuid,不同手机扫描,会出现不同的uuid值。
木木:iOS的uuid应该是对连接关系的一个定义
我:那如果同一个手机,无论什么时候扫描,无论卸载多少次app,对指定的那个外设,始终会扫描到同一个uuid,对吗?
xTT:目前是这样的
但是升级ios的系统的话,就不清楚了。没注意过
我:请问你们都是怎么绑定一个外设的,比如说首次连接的时候,将这个外设的什么东西保存本地,以后扫描到它的时候,直接自动去连接它?请问你们会怎么绑定?
iOS_Orz7:uuid
我:我担心uuid会不会改变啊
iOS_Orz7: 那你就操死硬件商去
我:以前的思路是这样的,外设把自己的mac地址通过自己的广播,把mac地址发给app,是用这种方式取得外设的mac地址的
xTT:用广播带mac更好
这样还避免的安卓和iOS切换使用同一个设备的问题
我:@xTT 我刚刚升级了手机的系统,原来是9.3的现在升级到9.3.1,然后再扫描外设,结果发现uuid完全没有变化,和9.3系统的uuid一样
我:各位请看看这个问题,该如何解决?外设跟手机配对了,首次可以扫描到,配对后,第二次及以后,就再也扫描不到了
我:在设置的蓝牙里面,对应蓝牙外设的名称左边,点击倒立的感叹号,然后忽略,才可以重新搜索到。
木木:不要酱紫
木木:retrieveConnectedPeripheralsWithServices
retrievePeripheralsWithIdentifiers
我:执行这个方法就可以搜索到吗?
木木:看头文件里的说明
我:谢谢
(centermanager调用retrievePeripheralsWithIdentifiers方法后(要传入参数uuid),果然搜索到这个原来无法搜索到的外设)
http://www.oschina.net/question/2399354_240682
“我的设备是支持ANCS协议的,但是每次配对后系统就会自动和我的设备连接,我无法搜索到这个设备”
就是因为支持ANCS协议,所以需要配对,所以会弹出配对alertView要你配对!
ANCS 用的时候有一点需要注意,iOS对于其他的BLE profile不需要配对绑定,唯独对ANCS要求配对绑定,这点注意一点:)
Byte数组-> NSData
Byte数组-> NSData
//Byte byte[] = {};
Byte byte[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
NSData *adata = [[NSData alloc] initWithBytes:byte length:24];
block方法实现
//实现的写法
[WphCmdCreator getMacAddress:^(NSString *mac){
LOG(@"%@",mac);
} fail:^(){
}];
//下面是声明的写法
// + (void)getMacAddress:(void(^)(NSString *mac))mac fail:(void(^)(void))fail;
自定义tableview cell的较好方法
http://blog.csdn.net/swingpyzf/article/details/10012779
字节处理崩溃与否
#pragma mark - 处理输入的字符串指令,会崩溃,野指针
- (NSData *)ToDealWithCommandString:(NSString *)String {
Byte byte[] = {};
int CRC = 0;
NSArray *array = [String componentsSeparatedByString:@" "];
for (int i =0; i < [array count]; i++) {
int value = [[array objectAtIndex:i] intValue];
NSLog(@"字节值== %d",value);
byte[i] = value;
CRC += value;
}
NSLog(@"自己%@",self);
int LastByteIndex = (unsignedint)array.count;
byte[LastByteIndex] = CRC;
NSData *data = [[NSData alloc] initWithBytes:byte length:[array count]+1];
LOG(@"已发送:%@",data);
return data;
}
#pragma mark - 处理输入的字符串指令,这样就不会崩溃
- (NSData *)ToDealWithCommandString:(NSString *)String {
int CRC = 0;
NSString * TheTwoCharacters = [String substringWithRange:NSMakeRange(0,2)];
int a0 = [self turnTheHexLiterals:TheTwoCharacters];
NSString * TheTwoCharacters2 = [String substringWithRange:NSMakeRange(2,2)];
int a1 = [self turnTheHexLiterals:TheTwoCharacters2];
NSString * TheTwoCharacters3 = [String substringWithRange:NSMakeRange(4,2)];
int a2 = [self turnTheHexLiterals:TheTwoCharacters3];
NSString * TheTwoCharacters4 = [String substringWithRange:NSMakeRange(6,2)];
int a3 = [self turnTheHexLiterals:TheTwoCharacters4];
NSString * TheTwoCharacters5 = [String substringWithRange:NSMakeRange(8,2)];
int a4 = [self turnTheHexLiterals:TheTwoCharacters5];
NSString * TheTwoCharacters6 = [String substringWithRange:NSMakeRange(10,2)];
int a5 = [self turnTheHexLiterals:TheTwoCharacters6];
NSString * TheTwoCharacters7 = [String substringWithRange:NSMakeRange(12,2)];
int a6 = [self turnTheHexLiterals:TheTwoCharacters7];
NSString * TheTwoCharacters8 = [String substringWithRange:NSMakeRange(14,2)];
int a7 = [self turnTheHexLiterals:TheTwoCharacters8];
NSString * TheTwoCharacters9 = [String substringWithRange:NSMakeRange(16,2)];
int a8 = [self turnTheHexLiterals:TheTwoCharacters9];
NSString * TheTwoCharactersa = [String substringWithRange:NSMakeRange(18,2)];
int a9 = [self turnTheHexLiterals:TheTwoCharactersa];
NSString * TheTwoCharactersb = [String substringWithRange:NSMakeRange(20,2)];
int aa = [self turnTheHexLiterals:TheTwoCharactersb];
NSString * TheTwoCharactersc = [String substringWithRange:NSMakeRange(22,2)];
int ab = [self turnTheHexLiterals:TheTwoCharactersc];
NSString * TheTwoCharactersd = [String substringWithRange:NSMakeRange(24,2)];
int ac = [self turnTheHexLiterals:TheTwoCharactersd];
NSString * TheTwoCharacterse = [String substringWithRange:NSMakeRange(26,2)];
int ad = [self turnTheHexLiterals:TheTwoCharacterse];
NSString * TheTwoCharactersf = [String substringWithRange:NSMakeRange(28,2)];
int ae = [self turnTheHexLiterals:TheTwoCharactersf];
CRC = a0+a1+a2+a3+a4+a5+a6+a7+a8+a9+aa+ab+ac+ad+ae;
CRC = CRC & 0xFF;
Byte byte[] = {a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,CRC};
NSData *data = [[NSData alloc] initWithBytes:byte length:16];
return data;
}
终端合并静态库
http://www.cnblogs.com/qingjoin/archive/2013/01/31/2886985.html
i386表示支持iphone模拟器,armv6应用在iphone3gs上,armv7应用在iphone4,armv7s应用在iphone4s以及iphone5,arm64应用在最新的iphone5s上。 lipo -create /Users/hope/Desktop/合并/4s跑出来的库/libIntelligentCommunication.a /Users/hope/Desktop/合并/6plus跑出来的库/libIntelligentCommunication.a -output /Users/hope/Desktop/合并/libIntelligentCommunication.a
终端更新所有第三方,更新所有第三方到最新版
Last login: Tue May 31 09:01:03 on console
Mac-mini:~ hope$ cd /Users/hope/Documents/mycode/CUBOT\ Band
Mac-mini:CUBOT Band hope$ ls
CUBOT Band CUBOT BandUITestsUMSocial_Sdk_5.2.1
CUBOT Band.xcodeproj PodFileWechat
CUBOT Band.xcworkspace Podfile.lock
CUBOT BandTests TencentOpenAPI
Mac-mini:CUBOT Band hope$ pod update
Update all pods
Updating local specs repositories
终端安装第三方,前提是svn共同使用的情况
Last login: Mon May 30 23:21:44 on ttys000
Mac-mini:~ hope$ cd /Users/hope/Documents/mycode/CUBOT\ Band
Mac-mini:CUBOT Band hope$ ls
CUBOT Band CUBOT BandUITestsUMSocial_Sdk_5.2.1
CUBOT Band.xcodeproj PodFileWechat
CUBOT Band.xcworkspace Podfile.lock
CUBOT BandTests TencentOpenAPI
Mac-mini:CUBOT Band hope$ pod install
Updating local specs repositories
这个是cocoapod 更新之后解决的问题
// No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found.
隐藏返回按钮
self.navigationItem.hidesBackButton =YES;
野指针 Thread 1: EXC_BAD_ACCESS(code=1,
Thread 1: EXC_BAD_ACCESS(code=1,
http://www.ithao123.cn/content-42653.html
拖约束注意事项一条
直接view顶四个边做约束,和拉到四个方向的顶,再拖约束是不同的
通知处理
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toDealData:) name:DataHasBeenHandRing object:nil];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:DataHasBeenHandRing object:nil];
}
数组声明时的注意事项
NSMutableArray *arr = [NSMutableArray array];//这个会出现问题,后面会被释放
NSMutableArray *arr2 = [[NSMutableArray alloc]init];//这个则不会
数组直接赋值,与类似initWithArray得到值是不同的,直接赋值的话(比如array= arr;)如果arr的元素减少,那么array也会一样减少,但是如果initWithArray得到的数组就不会变化,这是它们的不同点
设置title 颜色和大小
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
删除cocoapod下面的某一个第三方
http://www.jianshu.com/p/552f21a989ba
取得XIB的view
cell = [[[NSBundle mainBundle] loadNibNamed:@"DeviceManagerCell" owner:self options:nil] lastObject];
禁掉所有交互
[UIApplication sharedApplication].keyWindow.userInteractionEnabled = NO;
禁掉界面操作,等数据处理完成,再允许操作
当你发指令获取数据进行处理的时候,可以在界面开启一个菊花,让它转动,并且禁掉所有的操作,等数据处理完,再把菊花移除,此时才可以操作界面
覆盖导航栏的做法
[[UIApplication sharedApplication].keyWindow addSubview:UserUnableView];
代码被锁,解除方法
http://www.lai18.com/content/1159871.html
打印百分号
@"%d%%"/打印百分号只需要再加一个百分号再后面就行
创建一个基视图控制器, baseVC
创建一个所有视图控制器的父类BaseViewController,就可以轻而易举的为所有子类添加方法和属性
0xAABBCC转成整形十进制
Byte byte[] = {120,150,100};
int KaLuLi = [self hexLiteralsChangeToInt:byte];
NSLog(@"==%d",KaLuLi);
- (int)hexLiteralsChangeToInt:(Byte[])byte {
NSString *KAStr = nil;
if (byte[2] >15) {
KAStr = [NSString stringWithFormat:@"%X",byte[2]];
}else if (byte[2] <16) {
KAStr = [NSString stringWithFormat:@"0%X",byte[2]];
}
if (byte[1] >15) {
KAStr = [NSString stringWithFormat:@"%X%@",byte[1],KAStr];
}else if (byte[1] <16) {
KAStr = [NSString stringWithFormat:@"0%X%@",byte[1],KAStr];
}
if (byte[0] >15) {
KAStr = [NSString stringWithFormat:@"%X%@",byte[0],KAStr];
}else if (byte[0] <16) {
KAStr = [NSString stringWithFormat:@"0%X%@",byte[0],KAStr];
}
int KaLuLi = 0;
if (KAStr.length == 5) {
for (int i =0; i < 5; i ++) {
NSString *letter = [KAStr substringWithRange:NSMakeRange(i,1)];
int value = [self changeToIntString:letter];
if (i == 0) {
KaLuLi = value *16*16*16*16;
} else if (i == 1) {
KaLuLi += value*16*16*16;
}else if (i == 2) {
KaLuLi += value*16*16;
} else if (i == 3) {
KaLuLi += value*16;
}else if (i == 4) {
KaLuLi += value;
}
}
} else if (KAStr.length ==6) {
for (int i =0; i < 6; i ++) {
NSString *letter = [KAStr substringWithRange:NSMakeRange(i,1)];
int value = [self changeToIntString:letter];
if (i == 0) {
KaLuLi = value *16*16*16*16*16;
} else if (i == 1) {
KaLuLi += value*16*16*16*16;
}else if (i == 2) {
KaLuLi += value*16*16*16;
} else if (i == 3) {
KaLuLi += value*16*16;
}else if (i == 4) {
KaLuLi += value*16;
}else if (i == 5) {
KaLuLi += value;
}
}
}
return KaLuLi;
}
@"2016-5-31"转为NSDate
NSString * newDateStr = [NSString stringWithFormat:@"2016-%d-%d 12:00:00",month,day];//以后年的值必须替换为实时
NSDate * newDate = [Tool stringToDate:newDateStr];
+ (NSDate *)stringToDate:(NSString *)dateStr
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSTimeZone *timeZone = [NSTimeZone localTimeZone];
[formatter setTimeZone:timeZone];
[formatter setDateFormat : @"yyyy-MM-dd HH:mm:ss"];//设置日期格式 h大写表示24小写表示12小时制
NSDate *dateTime = [formatter dateFromString:dateStr];
return dateTime;
}
mac环境下svn的使用
//建仓的博客,搜索:mac环境下svn的使用
Reason: image not found 错误解决方法
dyld: Library not loaded: @rpath/OdmBleCoreSDK.framework/OdmBleCoreSDK
Referenced from: /var/containers/Bundle/Application/10BAC1D0-5F3F-4D9A-B55D-787A688B0441/CUBOT Band.app/CUBOT Band
Reason: image not found
把Build Phases里OdmBleCoreSDK.framework后边的选项修改成为Optional就可以了
iOS 后台运行
勾选三个选项(target - capabilities - backgroud modes - 勾选Audio and airPlay、uses bluetooth LE accessories和acts as a bluetooth LE accessory),实例一个对象,appdelegate的进入后台和返回前台的方法里面调用MMPDeepSleepPreventer的两个方法,即可