This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary { | |
subscript(jsonDict key: Key) -> [String:Any]? { | |
get { | |
return self[key] as? [String:Any] | |
} | |
set { | |
self[key] = newValue as? Value | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 静态库 | |
只编译不链接 | |
只要头文件在,无需设置依赖 | |
会打包进主工程二进制文件 | |
2. 动态库 | |
既编译又链接 | |
必须设置依赖 | |
不会打包进主工程二进制文件 | |
3. 当且仅当动态库依赖静态库时,才会copy静态库的代码到动态库二进制 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swift vs Objective-C | |
`?` 可选值 显式可选 vs 隐式可选 | |
异步编程方式 async 协程编程 vs OKBAsyncLoader | |
enum 枚举 可携带变量 vs 不可携带变量 | |
函数&方法抛异常 显式抛异常 vs 隐式抛异常 | |
并发 Task结构化并发 vs 非结构化并发 | |
模型序列化反序列化 原生支持Codable vs 第三方库支持 | |
泛型 强大的泛型 vs 鸡肋的泛型 | |
响应式编程,观察者模式 原生Combine vs 第三方库 RxSwift, RecativeCocoa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
插桩技术 | |
插桩技术是指将额外的代码注入程序中以收集运行时的信息,可分为两种: | |
(1)源代码插桩[Source Code Instrumentation(SCI)]:额外代码注入到程序源代码中。 | |
(2)二进制插桩(Binary Instrumentation):额外代码注入到二进制可执行文件中。 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat YNSelfSizingRoundPixelValue(CGFloat value) | |
{ | |
static CGFloat scale; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^(){ | |
scale = [UIScreen mainScreen].scale; | |
}); | |
return roundf(value * scale) / scale; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// This demo shows a bug of SwiftUI. It's related to the refresh logic of "List" | |
/// | |
/// The steps are: | |
/// 1. click "Go to next page" | |
/// 2. click "Click Me" | |
/// 3. Go back to home page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
# Created on 2020-03-12 15:56:36 | |
# Project: Girls | |
from pyspider.libs.base_handler import * | |
import os | |
import sys | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i = 0; | |
while (YES) { | |
@autoreleasepool { | |
NSString *string = [[NSString alloc] initWithFormat:@"%d", i]; | |
// or | |
// NSString *string = [[NSString alloc] init]; | |
[[string rac_willDeallocSignal] subscribeCompleted:^{ | |
NSLog(@"obj dealloc"); | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <XCTest/XCTest.h> | |
@interface ThreadNotSafetyTests : XCTestCase | |
// no crash | |
//@property (atomic) NSObject *obj; | |
// crash | |
@property (nonatomic) NSObject *obj; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MyObject : NSObject | |
@property NSString *name; | |
@end | |
@implementation MyObject | |
-(void)dealloc | |
{ | |
NSLog(@"dealloc"); | |
} | |
@end |
NewerOlder