随笔分类 -  OC

IOS-OC
摘要:kCGImagePropertyExifDictionary 引用错误使用 AVFoundation拍照 //获取图片 [outputImage captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) { CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImage... 阅读全文
posted @ 2014-03-18 15:14 cocoajin 阅读(1781) 评论(0) 推荐(0) 编辑
摘要:Objective-C中3种枚举比较及KVO两个小技巧一:oc的3种枚举for循环for in枚举块 如代码NSUInteger totalCount = 10000;NSMutableArray *array = [NSMutableArray arrayWithCapacity:totalCount]; //create an array including 10000 elementsfor (int i = 0; i<totalCount; i++) { array[i] = [@(i) stringValue];} //C Language For Loop Enu... 阅读全文
posted @ 2014-03-18 14:18 cocoajin 阅读(790) 评论(0) 推荐(0) 编辑
摘要:xcode 调试程序 lldb 使用一:lldb是什么https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/Introduction.htmlhttp://lldb.llvm.org/简单来说,就是xcode断点调试程序时的工具; 如果,断点下面 log处的 lldb绿色字体二:常用调试命令1: po 打印指针; 如图代码: 初始化 hello 为 nil,第一处打印为 nil,然后有两处重新赋值,和打印处断点; 在程序执行到第一.. 阅读全文
posted @ 2014-03-17 16:17 cocoajin 阅读(935) 评论(0) 推荐(0) 编辑
摘要:iOS kvo 结合 FBKVOController 的使用一:FBKVOControlloer是FaceBook开源的一个 在 iOS,maxOS上使用 kvo的 开源库; 提供了block和@selector(SEL) 的回调操作,很方便实用; https://github.com/facebook/KVOController二:示例: fbKVO = [FBKVOController controllerWithObserver:self]; [fbKVO observe:personOne keyPath:@"pName" options:NSKeyValueObs 阅读全文
posted @ 2014-03-14 15:12 cocoajin 阅读(4006) 评论(0) 推荐(0) 编辑
摘要:ios 推送app badge 数字累加操作;一:此数字需要后台配合:二:大致原理: 后台发推送时,第一次 传badge 为1,往后,依次累加操作即可; 当用户打开app时,app向后台发送请求,告诉后台,用户打开了app,并查看了指定推送信息,然后后台修改上面累加的推送badge值为0; 当再有推送时,继续操作即可!三:后台iOS一般的推送信息格式: $message = '{ "aps":{ "alert":"msg from baidu push", "sound":"", &qu 阅读全文
posted @ 2014-03-14 09:57 cocoajin 阅读(6596) 评论(0) 推荐(0) 编辑
摘要:一:使用百度推送,或是苹果自带的推送出,才配置好anps-cer文件之后,出现错误推送未找到应用程序的“aps-environment”的权利字符串错误二:错误原因: 此原因是配置好推送证书之后,没有配置相应的profile文件; 请 在 开发者中心,配置,相应推送 bundle id 的 profile文件;参考:http://www.cocoachina.com/bbs/read.php?tid=84471 阅读全文
posted @ 2014-03-12 16:56 cocoajin 阅读(541) 评论(0) 推荐(0) 编辑
摘要:AVAudioPlayer播放在线音频文件一:原里:AVAudioPlayer是不支持播放在线音频的,但是AVAudioPlayer有一个 initWithData的方法;我们可以把在线音频转换为NSdata;然后播放二:如代码: NSData *soundData = [sharedAppSettingsController getSoundUrl:defaultDictionaryID uri:soundUrl]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithData:soundData err... 阅读全文
posted @ 2014-03-11 11:41 cocoajin 阅读(5629) 评论(0) 推荐(0) 编辑
摘要:一:情景解决NSUserDefault 偶尔保存数据无效今天用NSUserDefault保存一些少量的数据,但是发现 setObject时,有时成功!有时就是不成功!二:解决方法 [[NSUserDefaults standardUserDefaults] setObject:selectedItemsArray forKey:kRisk_NEWS_PIN_DAO_Datas]; [[NSUserDefaults standardUserDefaults] synchronize]; 手动调用 synchronize方法即可参考:http://www.crifan.com/nsu... 阅读全文
posted @ 2014-02-25 16:39 cocoajin 阅读(1212) 评论(0) 推荐(0) 编辑
摘要:[CALayer release]: message sent to deallocated instance iOS内存过度释放问题解决方式:1:先找到过度释放的 内存指针 开启-僵尸模式:xcode---Product--scheme--Edit Scheme ----Diagnostics---选中 Enable Zombie Objects 然后 运行 程序 ,点出 崩溃;2:如果上面方式,还找不到 过度释放内存的指针; xcode--Product--Profile---选择 Zombiles 即可,会自动开启程序内存调度工具然后点击运行的程序,点出 崩溃的页面:出现如图,然后,点击 阅读全文
posted @ 2014-01-27 12:48 cocoajin 阅读(1044) 评论(0) 推荐(0) 编辑
摘要:iOS子线程操作检测版本更新,有新版本通知用户更新 CheckVersion一:如何使用:#import "CheckVersion.h" //输入你的app在appStore的 id [CheckVersion check_APP_UPDATE_WITH_APPID:@"350962117"];上述代码写完就可以了,当用户打开app检测到新版本时,为通知用户,更新,并显示最新版本的更新内容; 二:CheckVersion 类//// CheckVersion.h// TopProgressView//// Created by cocoajin on 阅读全文
posted @ 2014-01-21 11:02 cocoajin 阅读(1323) 评论(0) 推荐(0) 编辑
摘要:iOS arc和非arc 适用 宏1:使用宏+ (void)showAlertWithMessage:(NSString *)messages{ dispatch_async(dispatch_get_main_queue(), ^{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"版本更新提示" message:messages delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; 阅读全文
posted @ 2014-01-20 11:31 cocoajin 阅读(585) 评论(0) 推荐(0) 编辑
摘要:synthesis-of-weak-property-only-allowed-in-arc-or-gc-mode ARC属性错误提示:1:确认你的项目是 ARC环境;2:如果 ARC下出现上面的提示,那找到 项目里面 weak 的属性,改为 assign参考:http://stackoverflow.com/questions/18936209/synthesize-of-weak-property-is-only-allowed-in-arc-or-gc-mode-with-first-comp 阅读全文
posted @ 2014-01-18 13:19 cocoajin 阅读(527) 评论(0) 推荐(0) 编辑
摘要:iOS 本地通知 操作1:配置通知:然后退出程序;UILocalNotification *localNotif = [[UILocalNotification alloc] init];localNotif.fireDate = date; // date after 10 sec from nowlocalNotif.timeZone = [NSTimeZone defaultTimeZone];// Notification detailslocalNotif.alertBody = text; // text of you that you have fetched// Set t.. 阅读全文
posted @ 2014-01-18 11:20 cocoajin 阅读(293) 评论(0) 推荐(0) 编辑
摘要:iOS 检查app版本更新操作1:获取本地安装的版本信息:[NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], kRevisionNumber]2:根据appStore上的 appid查询 appStore上的版本信息: 调用接口:http://itunes.apple.com/lookup?id=350962117 id 是app的 在appStore的id 解析上述 阅读全文
posted @ 2014-01-17 14:14 cocoajin 阅读(2008) 评论(0) 推荐(0) 编辑
摘要:UITableView Scroll to top 手动设置tableview 滚动到 顶部[mainTableView scrollRectToVisible:CGRectMake(0,0,1,1) animated:YES];[mainTableView setContentOffset:CGPointZero animated:YES];参考:http://stackoverflow.com/questions/724892/uitableview-scroll-to-the-tophttp://stackoverflow.com/questions/19243177/how-to-sc 阅读全文
posted @ 2014-01-16 09:09 cocoajin 阅读(2715) 评论(0) 推荐(0) 编辑
摘要:xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code解决方法:方法一: ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:Api]]; __block ASIHTTPRequest *brRequest = request; [request setCompletionB... 阅读全文
posted @ 2014-01-15 15:40 cocoajin 阅读(4265) 评论(0) 推荐(0) 编辑
摘要:iOS key value coding kvc在接收json数据与 model封装中的使用使用 kvc 能够极大的简化代码工作,及以后的接口维护工作;1:先创建MovieModel类.h和 .m 注意Model类的属性根据 后台接口返回的 json数据 里面的字段对应,一一对应;// Created by cocoajin on 14-1-15.// Copyright (c) 2014年 www.zhgu.net. All rights reserved.//#import @interface MovieModel : NSObject@property (nonatomic,st... 阅读全文
posted @ 2014-01-15 15:31 cocoajin 阅读(1108) 评论(0) 推荐(0) 编辑
摘要:NSData 转 bytes 字节数据NSData *data = [NSData dataWithContentsOfFile:filePath];NSUInteger len = [data length];Byte *byteData = (Byte*)malloc(len);memcpy(byteData, [data bytes], len); NSString *strPath = @"/Users/user/Desktop/jkk.txt"; NSLog(@"string = %@",[[NSString alloc]initWithCon 阅读全文
posted @ 2014-01-15 11:26 cocoajin 阅读(7115) 评论(0) 推荐(0) 编辑
摘要:iOS exit(),abort(),assert()函数区别exit() 退出程序abort() 停止程序,assert()检查里面的参数如果为nil抛出异常; 阅读全文
posted @ 2014-01-13 09:45 cocoajin 阅读(2001) 评论(0) 推荐(0) 编辑
摘要:一:NSUserDefaults支持的数据格式有:NSNumber(Integer、Float、Double),NSString,NSData,NSArray,NSDictionary,BOOL类型;二:可以把自定义的对象,转换为NSData来达到存储对象到NSUserDefaults的目的;如代码: 1:model.h #import @interface ReplayModel : NSObject@property (nonatomic,strong)NSNumber *useTimes; //使用次数@property (nonatomic,strong)NSDate *a... 阅读全文
posted @ 2014-01-07 09:40 cocoajin 阅读(3424) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示