- 博客(71)
- 收藏
- 关注
原创 XMPPFramework整合
添加全局头文件// 1在Other里创建PCH文件// 2修改项目设置中的LLVM 7.1 - Language - Prefix Header,把PCH文件拖进去创建地址// 3pch文件路径是绝对路径,当项目文件夹位置发生改变,需重新设置pch文件路径,可以使用占位符 $(SRCROOT)来替代当前项目的目录
2016-06-30 15:28:43
358
原创 SQLite在iOS中的使用
先导入sqlite3.h的头文件#import "ViewController.h"//导入SQLite3的头文件#import //宏定义数据库文件路径#define kDatabaseFilePath [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/User.sqlite"]创建数据库文件-
2016-06-30 15:26:36
413
原创 网络检测
//创建网络连接状态管理对象 AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager manager]; //开始监听网络连接状态 [manager startMonitoring]; //设置网络连接状态变化时回调的block [manager setReachabilit
2016-06-30 15:24:15
392
原创 CATransition(转场动画)
@interface CATransition : CAAnimation//动画过渡类型(字符串)@property(copy) NSString *type;//动画过渡方向(字符串)@property(nullable, copy) NSString *subtype;//动画起点(在整体动画的百分比)@property float startProgress;//动画终
2016-06-30 09:20:17
434
原创 GCD网络加载图片
#import "UIImageView+WebCache.h"@implementation UIImageView (WebCache)- (void)setImageWithURL:(NSURL *)url { //加载网络数据 __block UIImage *image = nil; //创建串行队列 dispatch_queue_t queue
2016-06-30 09:16:04
691
原创 GCD
//1 同步添加多个任务到串行队列,串行执行,不新开线程//1.1 同步添加多个任务到串行队列,立即执行,任务之间串行执行,串行队列后面的任务需等待串行队列结束才会执行,所以无需新开线程//1.2 在已经处于串行队列里的任务中,创建同步添加任务的串行队列,会造成当前线程阻塞//2 异步添加多个任务到串行队列,任务之间串行执行,串行队列后面的任务无需等待插入的串行队列结束,所以会新
2016-06-30 09:15:14
404
原创 多线程应用(从网络加载图片)
#import "UIImageView+WebCache.h"@implementation UIImageView (WebCache)- (void)setImageWithURL:(NSURL *)url { //NSOperation来实现多线程 //创建并发队列 NSOperationQueue *queue = [[NSOperationQueue
2016-06-30 09:14:30
602
原创 锁
NSLock(互斥锁)@interface NSLock : NSObject @protocol NSLocking//上锁- (void)lock;//解锁- (void)unlock;@end互斥锁: (1)用于给某一段代码加锁,如果在某个线程中被上锁,在另外线程中就无法同时访问被上锁的一段代码。需要等待上锁的线程解锁后才能进行继续操作。
2016-06-30 09:13:48
403
原创 NSThread(线程)
创建线程//方式1 initNSThread *thread1 = [[NSThread alloc] initWithTarget:self selector:@selector(action1) object:nil]; //方式2 子类化NSThread,覆写-(void)main//方式3[self performSelectorInBackground:@sele
2016-06-30 09:12:49
315
原创 录音与播放
#import "ViewController.h"//导入AVFoundation框架#import @interface ViewController (){ NSURL *recordURL; AVAudioPlayer *player; AVAudioRecorder *recorder;}@end@implementation ViewCont
2016-06-28 17:00:02
686
原创 KVO(键值观察)
添加键值观察者@interface NSObject(NSKeyValueObserverRegistration)- (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(nullable void
2016-06-28 16:47:40
370
原创 UIGestureRecognizer(手势识别器)
@interface UIGestureRecognizer : NSObjectUITapGestureRecognizer(点击手势识别器)//点击次数@property (nonatomic) NSUInteger numberOfTapsRequired;//触碰点数@property (nonatomic) NSUInteger numberOfTouchesReq
2016-06-28 16:41:30
442
原创 内存管理
ARCproperty的修饰符总结· strong相当于MRR中的retain。· weak相当于MRR中可以使用对象的assign· copy:之前的copy一样, 复制一个对象并创建strong关联。· assign:对象不能使用assign,基本数据类型(BOOL、int、float)仍然可以使用。ARC、MRR的使 标记· 对于某些我们不希望使用 ARC 的文件,
2016-06-28 16:16:42
335
原创 UINavigationController、UITabBarController
UINavigationBar(导航栏)@interface UINavigationController : UIViewController//navigationBar是UINavigationController的一个属性@property(nonatomic,readonly) UINavigationBar *navigationBar;//是否隐藏@property(n
2016-06-28 15:32:47
428
原创 application、view的生命周期
// 当应用程序将要进入非活动状态时执行,在此期间,应用程序不接收消息或事件,如电话、锁屏等- (void)applicationWillResignActive:(UIApplication *)application { NSLog(@"非活动状态执行");}// 程序进入后台- (void)applicationDidEnterBackground:(UIApplicati
2016-06-28 15:22:39
551
原创 OC一些基本类以及方法
NSObject1、isKindOf://判断是否是该类的对象- (BOOL)isKindOfClass:(Class)aClass;BOOL result = [person isKindOfClass:[Person class]];返回值:BOOL类型aClass:可以是父类也可以是本类[Person class]:返回类名2、isMemberOf://判断是否是该
2016-06-28 15:19:50
442
原创 Block
Block语法定义Block变量定义: 返回值 (^变量名)(函数参数..)int (^ myBlocks)(int);Block函数的创建myBlocks= ^(int a){ int result = a * a; return result;};Block函数的调用int ret = myBlocks(10);
2016-06-15 19:19:24
371
原创 XMPP实现好友注册,登陆,收发消息
XMPPManager.h#import #import "XMPPFramework.h"//宏定义通知名#define kRecieveMessageNotification @"RecieveMessageNotification"//定义登陆成功失败blocktypedef void(^LoginSuccessBlock)(void);typedef void(^Login
2016-06-15 16:01:29
585
原创 NSFetchedResultsController(查询结果控制器)
ListTableViewController.h //ListTableViewController是UITableViewController子类@interface ListTableViewController : UITableViewController@endListTableViewController.m#import "ListTableViewControl
2016-06-15 09:54:27
542
原创 CoreData的外键关联
//创建工程时勾选Use Core Data自动生成好多方法1对1 AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; //通过实体描述创建第一个对象对象 Person *person = [NSEntityDescription insertNewObjectForEnt
2016-06-14 20:51:20
651
原创 CoreData使用
CoreData的使用头文件导入和全局变量#import { NSManagedObjectContext *_objectContext; }创建图形上下文 //1 创建数据库文件路径 NSString *dataBaseFilePath = [NSHomeDirectory() stringByAppendingPathComponent:@"
2016-06-14 20:28:05
348
原创 SQLite用于用户管理
User.h文件#import @interface User : NSObject@property (nonatomic, copy) NSString *username;@property (nonatomic, copy) NSString *password;@property (nonatomic, assign) NSUInteger age;@endD
2016-06-13 20:37:45
1280
原创 SQLite语句
SQL的使用1. DDL数据定义语言2. DML数据操作语言3. DQL数据查询语言注意:1. SQL语句在执行时不区分大小写,为了书写规范一律大写2. 表格名,字段名不能和关键词同名3. 每一个SQL语句都以;结尾DDL语句创建表格 CREATE TABLECREATE TABLE 表格名 (字段1 字段1的类型, 字段2 字段2的类型,
2016-06-13 19:41:53
435
原创 CocoaPods安装
安装要先装Ruby,然后在终端里sudo gem install CocoaPods,安装CocoaPods。如果半天没反应,应该是被墙了,需要:$ gem sources --remove https://rubygems.org/ //等有反应之后再敲入以下命令$ gem sources -a https://ruby.taobao.org/为了验证你的Ruby镜像是并且仅是
2016-06-07 20:51:14
345
原创 KissXML的使用
创建 //创建根元素结点 GDataXMLElement *rootElement = [GDataXMLElement elementWithName:@"China"]; NSArray *provinces = @[@"Henan", @"Zhejiang", @"Jiangsu"]; NSArray *citys = @[@[@"郑州", @"洛阳"]
2016-06-07 20:13:32
545
原创 AFNetworking实现上传
- (IBAction)startUploadTask:(id)sender { //网络地址 NSString *urlString = @"https://api.weibo.com/2/statuses/upload.json"; //创建access_token NSString *token = @"2.00hd363CtKpsnBedca9b3f35t
2016-06-07 20:06:50
409
原创 AFNetworking实现下载
- (IBAction)downLoad:(id)sender { //下载地址 NSString *urlString = @"http://218.76.27.57:8080/chinaschool_rs02/135275/153903/160861/160867/1370744550357.mp3"; //创建manager AFHTTPSessionMana
2016-06-06 20:58:02
345
原创 AFNetworking实现网络请求
GET请求- (IBAction)get:(id)sender { //网址字符串 NSString *urlString = @"http://piao.163.com/m/cinema/list.html?app_id=1&mobileType=iPhone&ver=2.6&channel=appstore&deviceId=9E89CB6D-A62F-438C-8010
2016-06-06 20:02:14
366
原创 NSURLSessionUploadTask(上传任务)
通过POST网络请求发送一条带图片文字的微博 //构建URL NSURL *url = [NSURL URLWithString:@"https://upload.api.weibo.com/2/statuses/upload.json"]; //构建请求对象 NSMutableURLRequest *request = [NSMutableURLRequest
2016-06-06 19:51:27
710
原创 NSURLSessionDownloadTask(下载任务)
#import "ViewController.h"//宏定义继续任务的plist文件路径#define kResumeDataPath [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/resumeData.plist"]@interface ViewController () NSURLSessionDownlo
2016-06-05 23:42:19
583
原创 通过NSURLSessionConfiguration构建NSURLSessionDataTask
//1构建网络地址 NSURL *url = [NSURL URLWithString:@"http://218.76.27.57:8080/chinaschool_rs02/135275/153903/160861/160867/1370744550357.mp3"]; //2构建会话的配置对象 /* defaultSessionConfiguration;
2016-06-05 23:17:54
412
原创 使用默认的网络会话进行网络请求
//1构建网络地址 NSURL *url = [NSURL URLWithString:@"http://www.weather.com.cn/data/sk/101010300.html"]; //2构建网络请求 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
2016-06-05 22:52:53
435
原创 GCD高级使用
GCD高级使用任务组(dispatch_group_t)- (void)taskGroup { //创建任务组 dispatch_group_t group = dispatch_group_create(); //获取全局队列 dispatch_queue_t globalQueue = dispatch_get_global_queue(DISPATCH
2016-06-03 19:51:11
353
原创 GCD简单使用
GCD高级使用任务组(dispatch_group_t)- (void)taskGroup { //创建任务组 dispatch_group_t group = dispatch_group_create(); //获取全局队列 dispatch_queue_t globalQueue = dispatch_get_global_queue(DISPATCH
2016-06-03 19:46:28
381
原创 动画暂停与继续
暂停 //计算暂停时间 CFTimeInterval pauseTime = [_myView.layer convertTime:CACurrentMediaTime() fromLayer:nil]; //把图层速度设置为0 _myView.layer.speed = 0; //设置时间偏移值为暂停时时间 _myView.layer.timeO
2016-06-02 15:27:46
348
原创 CABasicAnimation CAKeyframeAnimation CAAnimationGroup
CABasicAnimation(基本动画)@interface CAPropertyAnimation : CAAnimation//创建带路径的动画+ (instancetype)animationWithKeyPath:(nullable NSString *)path;//
2016-06-02 10:01:45
299
原创 CALayer
@interface UIView : UIResponder@property(nonatomic,readonly,strong) CALayer *layer; @interface CALayer : NSObject //背景颜色@property(nullable) CGColorRef backgroundColor;//圆角半径@
2016-06-02 09:21:40
309
原创 NSInvocationOperation、NSBlockOperation、NSOperationQueue
创建线程 //------------------------方式1------------------------ NSInvocationOperation *operation1 = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(operation1) object:nil];
2016-05-31 19:46:00
404
原创 三种传值(Block、代理协议、通知)
block1 发送者定义block类型,2 发送者创建block属性,3 发送者将参数封装进block中,4 接受者那里创建发送者对象,发送者调用带参数的block方法并实现处理数据的代码//1 定义block//returnType:返回类型,没有为void//^#name#>:Block名字//arguments:参数typedef #returnTy
2016-05-27 20:28:42
341
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人