_
q q__ __ _
4 '_ | | | |/ _` |
| 7_2 8 8_4 1 (_8 |
|_.__/ \__,_|\__, 2
|___/
没有足够的数据
Channe 关注了用户 · 2019-05-16
_
q q__ __ _
4 '_ | | | |/ _` |
| 7_2 8 8_4 1 (_8 |
|_.__/ \__,_|\__, 2
|___/
_q q__ __ _4 '_ | | | |/ _` || 7_2 8 8_4 1 (_8 ||_.__/ \__,_|\__, 2 {代码...}
关注 30
Channe 关注了标签 · 2019-04-26
Electron 是由 Github 开发,用 HTML,CSS 和 JavaScript 来构建跨平台桌面应用程序的一个开源库。
Electron 通过将 Chromium 和 Node.js 合并到同一个运行时环境中,并将其打包为 Mac,Windows 和 Linux 系统下的应用来实现这一目的。
Electron 是由 Github 开发,用 HTML,CSS 和 JavaScript 来构建跨平台桌面应用程序的一个开源库。Electron 通过将 Chromium 和 Node.js 合并到同一个运行时环境中,并将其打包为 Mac,Windows 和 Linux 系统下的应用来实现这一目的。
关注 461
Channe 赞了回答 · 2018-02-07
我不知道这个库,我稍微看了一下。
简单点说,当我们给一个NSNull对象发送消息的话,可能会崩溃(null是有内存的),而发送给nil的话,是不会崩溃的。
作者就是使用了这么一个原理,把发送给NSNull的而NSNull又无法处理的消息经过如下几步处理:
创建一个方法缓存,这个缓存会缓存项目中类的所有类名。
遍历缓存,寻找是否已经有可以执行此方法的类。
如果有的话,返回这个NSMethodSignature
。
如果没有的话,返回nil,接下来会走forwardInvocation:
方法。
[invocation invokeWithTarget:nil];
将消息转发给nil。
那么,如何判断NSNull无法处理这个消息呢,在OC中,系统如果对某个实例发送消息之后,它(及其父类)无法处理(比如,没有这个方法等),系统就会发送methodSignatureForSelector
消息,如果这个方法返回非空,那么就去执行返回的方法,如果为nil,则发送forwardInvocation
消息。
这样就完成整个转发链了。
题外话:
一般来说,我们不应该在我们的项目中使用NSNull类(大部分NSNull类的来源来自于接口的返回),而使用nil,在来源上,就应该堵上(要么你解析到null进行处理,要么和你的服务端说,不要给我返回null)。
我不知道这个库,我稍微看了一下。简单点说,当我们给一个NSNull对象发送消息的话,可能会崩溃(null是有内存的),而发送给nil的话,是不会崩溃的。作者就是使用了这么一个原理,把发送给NSNull的而NSNull又无法处理的消息经过如下几步处理:
关注 6 回答 2
Channe 赞了回答 · 2016-10-19
@interface XXX
@property (nonatomic, assign) NSInteger inputCount; //用户输入次数,用来控制延迟搜索请求
@end
- (void)inputBarTextViewDidChange:(HPGrowingTextView *)textView hasInputText:(NSString *)text {
// 用户停止输入1秒后进行提示内容匹配搜索
self.inputCount ++;
[self performSelector:@selector(requestKeyWorld:) withObject:@(self.inputCount) afterDelay:1.0f];
}
- (void)requestKeyWorld:(NSNumber *)count {
if (self.inputCount == [count integerValue]) {
//说明用户停止输入超过了一秒,发起网络请求
[self.searchOperation cancel];
//执行网络请求
self.searchOperation = [HTTP XXX];
}
}
{代码...}
关注 9 回答 6
Channe 回答了问题 · 2015-09-15
你的用法错了
NSNotificationCenter 的使用
1,定义一个方法
-(IBACtion)shuchu{ }
2,对象注册,并附带信息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shuchu) name:@"NotificationName" object:nil];
3,发送通知信息
[[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationName" object:nil];
4,dealloc中删除通知
[[NSNotificationCenter defaultCenter] removeObserver:self];
你的用法错了NSNotificationCenter 的使用1,定义一个方法-(IBACtion)shuchu{ }2,对象注册,并附带信息[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shuchu) name:@"NotificationName" object:nil];3,发送通知信息[[NSNotification...
关注 2 回答 1
Channe 回答了问题 · 2015-09-15
你都说了要数组,那为什么这么写?JSONStringWithNSDictionary?
[postDic setValue:[NSString JSONStringWithNSDictionary:self.orderModel.cartCids] forKey:@"cids"];
你都说了要数组,那为什么这么写?JSONStringWithNSDictionary? {代码...}
关注 5 回答 3
查看全部 个人动态 →
(゚∀゚ )
暂时没有
(゚∀゚ )
暂时没有
注册于 2011-05-27
个人主页被 856 人浏览
推荐关注