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
// Refer to https://stackoverflow.com/a/41543070/9315497 | |
// https://talk.objc.io/episodes/S01E31-mutating-untyped-dictionaries | |
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
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
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
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
插桩技术 | |
插桩技术是指将额外的代码注入程序中以收集运行时的信息,可分为两种: | |
(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
#!/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
Swift中,一个类实例的内存布局是有规律的: | |
1. 32位机器上,类前面有4+8个字节存储meta信息,64位机器上,有8+8个字节; | |
2. 内存中,字段从前往后有序排列; | |
3. 如果该类继承自某一个类,那么父类的字段在前; | |
4. Optional会增加一个字节来存储.None/.Some信息; | |
5. 每个字段需要考虑内存对齐; | |
这方面尚未从官方的资料找到参考,上述规律一些是从网上其他大神的总结中收集,一些从Clang的一些说明文档中挖掘,加上自己的反复验证得到。 | |
Refer to: https://www.jianshu.com/p/eac4a92b44ef |
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
// | |
// InterestTests.swift | |
// iOSHookTests | |
// | |
// Created by Yanni Wang on 25/4/20. | |
// Copyright © 2020 Yanni. All rights reserved. | |
// | |
import XCTest |
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
static CGFloat MDCFabs(CGFloat value) { | |
#if CGFLOAT_IS_DOUBLE | |
return fabs(value); | |
#else | |
return fabsf(value); | |
#endif | |
} | |
static BOOL MDCCGFloatEqual(CGFloat a, CGFloat b) { | |
const CGFloat constantK = 3; |
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 UIKit | |
class ViewController: UIViewController { | |
struct OneStruct { | |
} | |
class OneClass { | |
} |
NewerOlder