小众开发者 #Swift #Themes  Docker  Github
< Code is code />
  • C++ 17: 结构化绑定(Structured Binding)

    Aug 29, 2022

    结构化绑定(Structured Binding)是 C++ 17 的新特性,是一个很方便的语法糖。 typedef struct Rect { double x; double y; double width; double height; } Rect; Rect bounds{ 100, 100, 300, 400 }; auto [ x, y, w, h…

    C++

  • Swift 调用私有方法

    Aug 29, 2022

    _UICreateScreenUIImage 是用于生成屏幕快照的一个私有方法,效果类似按下截屏组合键,不过这个函数调用不会触发截屏音效。 在 Objective-C 里,只需要声明一下方法的原型就可以使用了。…

    Swift

  • Xcode 13 中优化 Swift 对象的生命周期

    Aug 28, 2022

    默认情况下,Swift 对象的生命周期如下: 在 WWDC 21 中 ARC in Swift: Basics and beyond ,新发布的 Xcode 13 增加了一个选项,用来优化 Swift 对象的生命周期: 当这个选项开启后,对象…

    Swift

  • ARC 与 AutoreleasePool

    Aug 27, 2022

    Objective-C 中的 ARC 与 AutoreleasePool Objective-C 中的对象在引用计数为 0 的时候就会被释放,为了解决手动管理引用计数(MRC)容易发生内存泄漏或者过度释放的问题,引入了自动引用计…

    Objective-CSwift

  • 使用 spctl 检查 App 的来源

    Aug 22, 2022

    spctl --assess --verbose XX.app 输出结果: 来自于 Apple 的软件: /Applications/Xcode.app: accepted source=Apple System 从 Mac App Store 下载的软件: /Applications/WeChat.app: accepted source=Mac App Store 开发者自己打包的软件: 没在在 Apple 进行公证: /Applications/Impactor.app: accepted source=Developer ID 进行了 Apple 公证: /Applications/Visual Studio Code.app:…

    macOS

  • C++ 中使用 RAII 的注意事项

    Aug 20, 2022

    RAII (Resource Acquisition Is Initialization) 翻译为中文是「资源获取即初始化」。 通常用来做局部资源清理或者防止忘记解锁导致死锁: class LockGuard { public: LockGuard() { lock(); } ~LockGuard() { unlock(); } private: static pthread_mutex_t _fastmutex; void lock() { pthread_mutex_lock(&_fastmutex); } void unlock() {…

    C++

  • Git 的稀疏检出(Sparse checkout)功能

    Aug 19, 2022

    Git clone 默认是完整检出整个仓库,如果只想检出某一部分文件或者目录,就需要用到稀疏检出功能(Sparse checkout)。 举个例子,我只对 Telegram iOS 源…

    Git

  • Swift 中的闭包(Closure)

    Aug 17, 2022

    普通闭包写法: let closure = { (data, error) in if let data = data { // handle data } } 使用闭包延迟求值: lazy var titleLabel = { () -> UILabel in let lable = UILabel() lable.font = .systemFont(ofSize: 13) lable.textColor = .systemOrange lable.textAlignment = .justified return lable }() 自动闭包 @autoclosure 修饰符,用…

    Swift

  • Swift 中的 Any 和 AnyObject

    Aug 17, 2022

    AnyObject :表示任意的 class 类型的实例,包括来自 ObjC 类和纯 Swift 的类,类似于 id 在 ObjC 里的概念。 Any :表示任意的类型实例,Swift 中的所有数据类型都可以用它表示。…

    Swift

  • Objective-C 中的轻量泛型(Lightweight Generics)

    Aug 14, 2022

    轻量泛型(Lightweight Generics)是 Xocde 7 开始增加的特性。 同时增加的另外两个新特性:可空性(Nullability)和 __ki…

    iOS

  • 1
  • 2
  • 3
  • 4
  • 5

©2021 lvvme.

Powered by Hugo & Notepadium ipv6 ready

粤公网安备 44030602004734号     粤ICP备20056596号-1