记录点滴

  • Home

  • About

  • Tags

  • Categories

  • Archives

OC Runtime之Associated Objects

Posted on 2016-07-11 | Edited on 2021-01-20 | In Runtime

什么是Associated Objects?

有时,我们希望为某个对象关联一些信息。一般地,我们会子类化,但是“黑魔法”Associated Objects(关联对象)使用起来就更方便了。使用关联对象,我们可以不用修改类的定义而为其对象增加存储空间(在 Objective-C 中可以通过 Category 给一个现有的类添加属性,但是却不能添加实例变量,这似乎成为了 Objective-C 的一个明显短板。然而值得庆幸的是,我们可以通过 Associated Objects 来弥补这一不足)。与它相关在中有3个C函数,它们可以让对象在运行时关联任何值:

Read more »

OC Runtime之动态方法解析和消息转发

Posted on 2016-07-10 | Edited on 2021-01-20 | In Runtime

首先直接上代码:

@interface Person : NSObject  
- (void)eat;  
- (void)say:(NSString*)world;  
@end  

@implementation AA  
- (void)eat {  
  NSLog(@"eat");  
}  
@end
Read more »

OC Runtime简述

Posted on 2016-07-09 | Edited on 2021-01-20 | In Runtime

什么是Runtime

Objective-C语言尽可能地将一些决定从编译时推迟到运行时,也就是说只有编译器是不够的,还需要一个运行时系统 (runtime system) 来执行编译后的代码。Objective-C Runtime系统是整个Objective-C语言的基石,它使Objective-C的动态特性成为可能。

与Runtime交互

Objc从三种不同的层级上与Runtime系统进行交互,分别是通过Objective-C源代码,通过 Foundation框架的NSObject类定义的方法,通过对runtime函数的直接调用。

Read more »

深挖NSTimer

Posted on 2016-07-06 | Edited on 2021-01-20 | In summary

1.没有scheduled方式初始化的,需要我们手动调用addTimer:forMode:方法,将timer添加到一个runloop中.

举例:

//默认添加到RunLoop中
NSTimer *timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO];
//手动添加到RunLoop中
NSTimer *timer2 = [NSTimer timerWithTimeInterval:3.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:timer2 forMode:NSDefaultRunLoopMode];
Read more »

ionic混合应用开发

Posted on 2016-05-30 | Edited on 2021-01-20 | In ionic

一、 什么是ionic

ionic 是一个专注于用WEB开发技术,基于HTML5创建类似于手机平台原生应用的一个开发框架。绑定了AngularJS框架。这个框架的目的是从web的角度开发手机应用。基于cordova的编译平台,可以实现编译成各个平台的应用程序。
更多背景介绍参考:这里

Read more »

iOS Socket编程

Posted on 2016-04-30 | Edited on 2021-01-20 | In 网络

什么是Socket

提起socket,我们不得不先看看TCP/IP协议族。

下图显示了TCP/IP协议四层之间的关系:

Read more »

开发中相关工具

Posted on 2016-02-06 | Edited on 2021-01-20 | In tools

iOS开发过程中使用到的相关工具

CocoaPods

CocoaPods安装和使用教程

Read more »
1…45

CXY

47 posts
25 categories
39 tags
© 2022 CXY
Powered by Hexo v3.7.1
|
Theme – NexT.Mist v7.0.0