<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>宋明 - 作者 - 宋明的博客</title><link>https://apolla.cc/authors/%E5%AE%8B%E6%98%8E/</link><description>宋明的博客</description><generator>Hugo 0.170.0 &amp; FixIt v1.0.0-rc.5-mwimukpl</generator><language>zh-cn</language><lastBuildDate>Thu, 20 Jun 2024 20:52:48 +0800</lastBuildDate><atom:link href="https://apolla.cc/authors/%E5%AE%8B%E6%98%8E/index.xml" rel="self" type="application/rss+xml"/><item><title>基础语法</title><link>https://apolla.cc/posts/%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95/</link><pubDate>Mon, 08 Apr 2024 15:42:24 +0800</pubDate><guid>https://apolla.cc/posts/%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;blockquote&gt;&#10;&lt;p&gt;用var定义变量，let定义常量，编译器能自动推断出变量\常量的类型&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h2 class="heading-element" id="常量"&gt;&lt;span&gt;常量&lt;/span&gt;&#10; &lt;a href="#%e5%b8%b8%e9%87%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ol&gt;&#10;&lt;li&gt;只能赋值1次&lt;/li&gt;&#10;&lt;li&gt;它的值不要求在编译时期确定，但使用之前必须赋值1次&#10;!&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h2 class="heading-element" id="常见数据类型"&gt;&lt;span&gt;常见数据类型&lt;/span&gt;&#10; &lt;a href="#%e5%b8%b8%e8%a7%81%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;!&lt;/p&gt;</description></item><item><title>1.5 SwiftUI 中的属性包装器</title><link>https://apolla.cc/posts/1.5-swiftui-%E4%B8%AD%E7%9A%84%E5%B1%9E%E6%80%A7%E5%8C%85%E8%A3%85%E5%99%A8/</link><pubDate>Wed, 11 Oct 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.5-swiftui-%E4%B8%AD%E7%9A%84%E5%B1%9E%E6%80%A7%E5%8C%85%E8%A3%85%E5%99%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;以下内容适用于 iOS 16/macOS 13 以上的系统，iOS 17/macOS 14 新增的 &lt;a href="https://developer.apple.com/documentation/observation" target="_blank" rel="external nofollow noopener noreferrer"&gt;Observation&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 框架简化了 SwiftUI 的状态管理，苹果的文档有非常详细的使用说明和迁移教程，笔者也写了一篇关于 Observation 的文章以供参考：&lt;a href="https://www.woter.xyz/blog/ios/swiftui/swiftui-observation-combine" target="_blank" rel="external nofollow noopener noreferrer"&gt;《有了 Observation，SwiftUI 还需要 Combine 吗》&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;。&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>1.3.3 模态（Modal）</title><link>https://apolla.cc/posts/1.3.3-%E6%A8%A1%E6%80%81modal/</link><pubDate>Tue, 10 Oct 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3.3-%E6%A8%A1%E6%80%81modal/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;模态是除导航之外的另一种重要的信息呈现方式，它通常以一种临时的界面和用户交互。如果把导航栈内的界面比作“主线”的话，模态就是分出来的“支线”。模态视图完成它的使命后，用户最终会回归至“主线”情景。&lt;/p&gt;&#10;&lt;p&gt;关于模态的更多设计语言以及使用场景，可以参考 &lt;a href="https://developer.apple.com/design/human-interface-guidelines/patterns/modality" target="_blank" rel="external nofollow noopener noreferrer"&gt;《人机界面指南》&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;。&lt;/p&gt;</description></item><item><title>4.3 图表（Charts）</title><link>https://apolla.cc/posts/4.3-%E5%9B%BE%E8%A1%A8charts/</link><pubDate>Tue, 10 Oct 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.3-%E5%9B%BE%E8%A1%A8charts/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="基础"&gt;&lt;span&gt;基础&lt;/span&gt;&#10; &lt;a href="#%e5%9f%ba%e7%a1%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/charts" target="_blank" rel="external nofollow noopener noreferrer"&gt;Charts&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 是 iOS 16/macOS 13 的新特性，用于构建各种精美的图表，如柱状图、散点图、曲线图等。&lt;/p&gt;</description></item><item><title>1.4 SwiftUI 视图管理机制</title><link>https://apolla.cc/posts/1.4-swiftui-%E8%A7%86%E5%9B%BE%E7%AE%A1%E7%90%86%E6%9C%BA%E5%88%B6/</link><pubDate>Wed, 02 Aug 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.4-swiftui-%E8%A7%86%E5%9B%BE%E7%AE%A1%E7%90%86%E6%9C%BA%E5%88%B6/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="视图的身份标识identity"&gt;&lt;span&gt;视图的身份标识（Identity）&lt;/span&gt;&#10; &lt;a href="#%e8%a7%86%e5%9b%be%e7%9a%84%e8%ba%ab%e4%bb%bd%e6%a0%87%e8%af%86identity" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;在 UIKit/AppKit 的世界，UIView/NSView 实例是引用类型（class），程序通过指针来引用和区分对象。要实现界面的更新，我们首先需要找到对应的视图，然后下达相应的指令，比如改变视图的位置或者颜色，然后界面才会随之更新，这是典型的命令式编程。&lt;/p&gt;</description></item><item><title>3.5 滑动视图（ScrollView）</title><link>https://apolla.cc/posts/3.5-%E6%BB%91%E5%8A%A8%E8%A7%86%E5%9B%BEscrollview/</link><pubDate>Tue, 25 Jul 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.5-%E6%BB%91%E5%8A%A8%E8%A7%86%E5%9B%BEscrollview/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="基础"&gt;&lt;span&gt;基础&lt;/span&gt;&#10; &lt;a href="#%e5%9f%ba%e7%a1%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;ScrollView 初始化方法如下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;init(&#10; _ axes: Axis.Set = .vertical,&#10; showsIndicators: Bool = true,&#10; content: () -&amp;gt; Content&#10;)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;axes&lt;/code&gt; 用于指定滑动的方向，默认是垂直方向。&lt;/p&gt;</description></item><item><title>2.2 图片</title><link>https://apolla.cc/posts/2.2-%E5%9B%BE%E7%89%87/</link><pubDate>Mon, 24 Jul 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.2-%E5%9B%BE%E7%89%87/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="image"&gt;&lt;span&gt;Image&lt;/span&gt;&#10; &lt;a href="#image" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/image" target="_blank" rel="external nofollow noopener noreferrer"&gt;Image&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 用于展示图片，它可以加载资源包（Bundle）中的图片和系统内置的图标。&lt;/p&gt;</description></item><item><title>4.4 基础动画</title><link>https://apolla.cc/posts/4.4-%E5%9F%BA%E7%A1%80%E5%8A%A8%E7%94%BB/</link><pubDate>Mon, 24 Jul 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.4-%E5%9F%BA%E7%A1%80%E5%8A%A8%E7%94%BB/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;视图是数据状态的反映，状态的更新会驱动视图的更新。如果没有动画过渡，视图的变化会显得突兀。SwiftUI 提供了几种基于状态的动画，这些都是非常常用和基础的添加动画的方式。&lt;/p&gt;&#10;&lt;h1 class="heading-element" id="animation-方法"&gt;&lt;span&gt;.animation 方法&lt;/span&gt;&#10; &lt;a href="#animation-%e6%96%b9%e6%b3%95" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;修饰器方法 &lt;a href="https://developer.apple.com/documentation/swiftui/view/animation(_:value:)" target="_blank" rel="external nofollow noopener noreferrer"&gt;animation(_:value:)&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 可以方便的创建动画，它的声明如下：&lt;/p&gt;</description></item><item><title>4.5 转场动画</title><link>https://apolla.cc/posts/4.5-%E8%BD%AC%E5%9C%BA%E5%8A%A8%E7%94%BB/</link><pubDate>Mon, 24 Jul 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.5-%E8%BD%AC%E5%9C%BA%E5%8A%A8%E7%94%BB/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="内置转场动画"&gt;&lt;span&gt;内置转场动画&lt;/span&gt;&#10; &lt;a href="#%e5%86%85%e7%bd%ae%e8%bd%ac%e5%9c%ba%e5%8a%a8%e7%94%bb" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;转场动画用于视图的添加、移除，使用如下方法为视图添加转场：&lt;/p&gt;</description></item><item><title>3.6 列表（List）</title><link>https://apolla.cc/posts/3.6-%E5%88%97%E8%A1%A8list/</link><pubDate>Mon, 05 Jun 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.6-%E5%88%97%E8%A1%A8list/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="list"&gt;&lt;span&gt;List&lt;/span&gt;&#10; &lt;a href="#list" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="构建"&gt;&lt;span&gt;构建&lt;/span&gt;&#10; &lt;a href="#%e6%9e%84%e5%bb%ba" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;h3 class="heading-element" id="基础"&gt;&lt;span&gt;基础&lt;/span&gt;&#10; &lt;a href="#%e5%9f%ba%e7%a1%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/list" target="_blank" rel="external nofollow noopener noreferrer"&gt;List&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 提供了非常多的构建方法，各方法的入参有细微的差别，支持的平台也不尽相同，所以使用时需要小心一些，遇到疑问时及时查看文档。&lt;/p&gt;</description></item><item><title>2.3 视图样式与行为</title><link>https://apolla.cc/posts/2.3-%E8%A7%86%E5%9B%BE%E6%A0%B7%E5%BC%8F%E4%B8%8E%E8%A1%8C%E4%B8%BA/</link><pubDate>Sat, 06 May 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.3-%E8%A7%86%E5%9B%BE%E6%A0%B7%E5%BC%8F%E4%B8%8E%E8%A1%8C%E4%B8%BA/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="字体"&gt;&lt;span&gt;字体&lt;/span&gt;&#10; &lt;a href="#%e5%ad%97%e4%bd%93" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;strong&gt;SwiftUI&lt;/strong&gt; 内置了许多不同大小的字体，它们具有动态缩放特性：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;在不同设备上动态缩放。&lt;/li&gt;&#10;&lt;li&gt;在支持动态缩放的 App 中，根据手机设置的字体大小动态缩放。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt;&lt;/p&gt;</description></item><item><title>2.8 使用 UIKit、AppKit</title><link>https://apolla.cc/posts/2.8-%E4%BD%BF%E7%94%A8-uikitappkit/</link><pubDate>Thu, 23 Feb 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.8-%E4%BD%BF%E7%94%A8-uikitappkit/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;SwiftUI 目前仍在发展中，相比古老而健壮的 UIKit/AppKit，它相对年轻，在生产实践中，有时我们需要借助 UIKit/AppKit 来实现 SwiftUI 难以实现的功能。&lt;/p&gt;&#10;&lt;p&gt;以下仅以 UIKit 为例进行说明，AppKit 与此类似。&lt;/p&gt;&#10;&lt;h1 class="heading-element" id="使用-uikit"&gt;&lt;span&gt;使用 UIKit&lt;/span&gt;&#10; &lt;a href="#%e4%bd%bf%e7%94%a8-uikit" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="uiviewrepresentable"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/uiviewrepresentable" target="_blank" rel="external nofollow noopener noreferrer"&gt;UIViewRepresentable&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#uiviewrepresentable" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;SwiftUI 通过 UIViewRepresentable 协议可以调用 UIKit 中的视图，比如想使用 UISearchBar：&lt;/p&gt;</description></item><item><title>5.3 自定义手势</title><link>https://apolla.cc/posts/5.3-%E8%87%AA%E5%AE%9A%E4%B9%89%E6%89%8B%E5%8A%BF/</link><pubDate>Sun, 29 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/5.3-%E8%87%AA%E5%AE%9A%E4%B9%89%E6%89%8B%E5%8A%BF/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;SwiftUI 内置了一些常用手势，它们都实现了 &lt;a href="https://developer.apple.com/documentation/swiftui/gesture" target="_blank" rel="external nofollow noopener noreferrer"&gt;Gesture&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 协议。&lt;/p&gt;&#10;&lt;p&gt;如果需要自定义手势，也需要实现该协议，其声明如下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;public protocol Gesture {&#10;&#10; /// The type representing the gesture&amp;#39;s value.&#10; associatedtype Value&#10;&#10; /// The type of gesture representing the body of `Self`.&#10; associatedtype Body : Gesture&#10;&#10; /// The content and behavior of the gesture.&#10; var body: Self.Body { get }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;和 View 协议类似，body 属性是必须实现的，它的类型由关联类型 Body 定义。另一个关联类型 Value 用于保存手势的状态，在 &lt;code&gt;.onChange&lt;/code&gt; 、 &lt;code&gt;.udpating&lt;/code&gt; 等监听方法中返回该状态。&lt;/p&gt;</description></item><item><title>5.1 常见手势</title><link>https://apolla.cc/posts/5.1-%E5%B8%B8%E8%A7%81%E6%89%8B%E5%8A%BF/</link><pubDate>Sat, 28 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/5.1-%E5%B8%B8%E8%A7%81%E6%89%8B%E5%8A%BF/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h2 class="heading-element" id="tapgesturespatialtapgesture"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/tapgesture" target="_blank" rel="external nofollow noopener noreferrer"&gt;TapGesture&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;、&lt;a href="https://developer.apple.com/documentation/swiftui/spatialtapgesture" target="_blank" rel="external nofollow noopener noreferrer"&gt;SpatialTapGesture&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#tapgesturespatialtapgesture" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;要为视图添加点击手势，可以使用 &lt;a href="https://developer.apple.com/documentation/swiftui/view/gesture(_:including:)" target="_blank" rel="external nofollow noopener noreferrer"&gt;gesture(_:including:)&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 绑定一个 TapGesture 实例至视图，也可以直接在视图上使用 &lt;code&gt;.onTapGesture&lt;/code&gt; 方法。&lt;/p&gt;</description></item><item><title>5.2 手势的管理</title><link>https://apolla.cc/posts/5.2-%E6%89%8B%E5%8A%BF%E7%9A%84%E7%AE%A1%E7%90%86/</link><pubDate>Sat, 28 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/5.2-%E6%89%8B%E5%8A%BF%E7%9A%84%E7%AE%A1%E7%90%86/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="手势的状态监听"&gt;&lt;span&gt;手势的状态监听&lt;/span&gt;&#10; &lt;a href="#%e6%89%8b%e5%8a%bf%e7%9a%84%e7%8a%b6%e6%80%81%e7%9b%91%e5%90%ac" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;《常见手势》 演示了通过 &lt;code&gt;.onChanged&lt;/code&gt; 和 &lt;code&gt;.onEnded&lt;/code&gt; 分别监听手势的变化和结束。&lt;/p&gt;</description></item><item><title>4.7 动画的进阶使用</title><link>https://apolla.cc/posts/4.7-%E5%8A%A8%E7%94%BB%E7%9A%84%E8%BF%9B%E9%98%B6%E4%BD%BF%E7%94%A8/</link><pubDate>Tue, 17 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.7-%E5%8A%A8%E7%94%BB%E7%9A%84%E8%BF%9B%E9%98%B6%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;h1 class="heading-element" id="transaction"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/transaction" target="_blank" rel="external nofollow noopener noreferrer"&gt;Transaction&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#transaction" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;事务（Transaction）是当前状态更新的上下文，包含状态变化过程中的动画。&lt;/p&gt;</description></item><item><title>4.6 动画原理</title><link>https://apolla.cc/posts/4.6-%E5%8A%A8%E7%94%BB%E5%8E%9F%E7%90%86/</link><pubDate>Fri, 13 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.6-%E5%8A%A8%E7%94%BB%E5%8E%9F%E7%90%86/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;h1 class="heading-element" id="animatable-协议"&gt;&lt;span&gt;Animatable 协议&lt;/span&gt;&#10; &lt;a href="#animatable-%e5%8d%8f%e8%ae%ae" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;我们之所以能看见动画的效果，是因为 SwiftUI 在视图变化的首尾状态之间不断地重绘视图，一系列静态视图因“视觉暂留”作用而造成一种连续的视觉印象，让我们感觉视图动起来了，这其实也是电影的原理。比如一个视图需要从透明度 0 变成 1，SwiftUI 会在 0 和 1 之间不断地作插值运算，不断重绘不同透明度的视图（0，0.1，0.2，0.3 &amp;hellip; 1.0），直到视图不再变化。如果使用 &lt;code&gt;.linear&lt;/code&gt; 指定动画效果，那么视图的重绘过程是匀速的，如果使用 &lt;code&gt;.easeOut&lt;/code&gt;，那么重绘的过程是先快后慢，以此类推。&lt;/p&gt;</description></item><item><title>4.2 图形的绘制</title><link>https://apolla.cc/posts/4.2-%E5%9B%BE%E5%BD%A2%E7%9A%84%E7%BB%98%E5%88%B6/</link><pubDate>Mon, 09 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.2-%E5%9B%BE%E5%BD%A2%E7%9A%84%E7%BB%98%E5%88%B6/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;h1 class="heading-element" id="canvas-的使用"&gt;&lt;span&gt;Canvas 的使用&lt;/span&gt;&#10; &lt;a href="#canvas-%e7%9a%84%e4%bd%bf%e7%94%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;Canvas 字面意思就是“画布”，在这个画布上可以绘制各种图形。与 Shape 不同的是，Canvas 支持即时绘制，比如用户可以使用手指在屏幕上涂鸦。&lt;/p&gt;</description></item><item><title>3.9 自定义布局（Layout）</title><link>https://apolla.cc/posts/3.9-%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B8%83%E5%B1%80layout/</link><pubDate>Sat, 07 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.9-%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B8%83%E5%B1%80layout/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;SwiftUI 内置了丰富的布局容器，也支持简单的布局调整，它们能够解决大多数常用的布局需求。但仍然有所限制，比如 HStack 或者 VStack，它们只能在单一线性轴上进行布局，Grid 虽然可以兼顾横向和纵向，但子视图的位置不能随意调整。&lt;/p&gt;&#10;&lt;p&gt;而 Layout 协议支持自定义布局，我们可以使用它随心所欲地实现各种纷繁的布局效果。&lt;/p&gt;</description></item><item><title>4.1 形状（Shapes）的使用</title><link>https://apolla.cc/posts/4.1-%E5%BD%A2%E7%8A%B6shapes%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Sat, 07 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4.1-%E5%BD%A2%E7%8A%B6shapes%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="常用的内置形状及样式"&gt;&lt;span&gt;常用的内置形状及样式&lt;/span&gt;&#10; &lt;a href="#%e5%b8%b8%e7%94%a8%e7%9a%84%e5%86%85%e7%bd%ae%e5%bd%a2%e7%8a%b6%e5%8f%8a%e6%a0%b7%e5%bc%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="内置形状"&gt;&lt;span&gt;内置形状&lt;/span&gt;&#10; &lt;a href="#%e5%86%85%e7%bd%ae%e5%bd%a2%e7%8a%b6" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;SwiftUI 内置了一些常用的形状，比如矩形、椭圆、正圆等。&lt;/p&gt;</description></item><item><title>3.7 表格（Table）</title><link>https://apolla.cc/posts/3.7-%E8%A1%A8%E6%A0%BCtable/</link><pubDate>Fri, 06 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.7-%E8%A1%A8%E6%A0%BCtable/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;</description></item><item><title>3.11 SwiftUI 布局总结</title><link>https://apolla.cc/posts/3.11-swiftui-%E5%B8%83%E5%B1%80%E6%80%BB%E7%BB%93/</link><pubDate>Thu, 05 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.11-swiftui-%E5%B8%83%E5%B1%80%E6%80%BB%E7%BB%93/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;pre&gt;&lt;code&gt;fileprivate struct ViewTransforming: View {&#10; @State private var aspectRatio: CGFloat = 1.0&#10; &#10; var body: some View {&#10; GroupBox(&amp;#34;aspectRatio&amp;#34;) {&#10; Rectangle()&#10; .fill(.blue.gradient)&#10; .aspectRatio(aspectRatio, contentMode: .fit)&#10; .frame(width: 80)&#10; LabeledContent(&amp;#34;aspectRatio: \(aspectRatio, specifier: &amp;#34;%.1f&amp;#34;)&amp;#34;) {&#10; Slider(value: $aspectRatio, in: 0.5...2.0)&#10; }&#10; }&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/57243677/proportional-height-or-width-in-swiftui" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/57243677/proportional-height-or-width-in-swiftui&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;静态渲染适用于轻量的数据展示，比如 HStack、Grid 等，它们的内容和尺寸都相对固定。SwiftUI 会计算它们包含的所有视图，无论该视图是在屏幕内或屏幕外，如果有少量的视图需要渲染，使用它们是非常合适的。&lt;/p&gt;</description></item><item><title>3.8 共享布局信息</title><link>https://apolla.cc/posts/3.8-%E5%85%B1%E4%BA%AB%E5%B8%83%E5%B1%80%E4%BF%A1%E6%81%AF/</link><pubDate>Thu, 05 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.8-%E5%85%B1%E4%BA%AB%E5%B8%83%E5%B1%80%E4%BF%A1%E6%81%AF/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="geometryreader"&gt;&lt;span&gt;GeometryReader&lt;/span&gt;&#10; &lt;a href="#geometryreader" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/geometryreader" target="_blank" rel="external nofollow noopener noreferrer"&gt;GeometryReader&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 视图的构建闭包内返回了一个 &lt;a href="https://developer.apple.com/documentation/swiftui/geometryproxy" target="_blank" rel="external nofollow noopener noreferrer"&gt;GeometryProxy&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 类型的结构体，通过它可以获取到如下信息：&lt;/p&gt;</description></item><item><title>3.2.1 视图组</title><link>https://apolla.cc/posts/3.2.1-%E8%A7%86%E5%9B%BE%E7%BB%84/</link><pubDate>Wed, 04 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.2.1-%E8%A7%86%E5%9B%BE%E7%BB%84/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="group"&gt;&lt;span&gt;Group&lt;/span&gt;&#10; &lt;a href="#group" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;前面提到过 SwiftUI 能够将各种视图组合在一起，得益于结果生成器，关于结果生成器，参考 《Swift 中的 Result builders》 。&lt;/p&gt;</description></item><item><title>3.4 格子（Grids）</title><link>https://apolla.cc/posts/3.4-%E6%A0%BC%E5%AD%90grids/</link><pubDate>Wed, 04 Jan 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.4-%E6%A0%BC%E5%AD%90grids/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="grid"&gt;&lt;span&gt;Grid&lt;/span&gt;&#10; &lt;a href="#grid" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/grid" target="_blank" rel="external nofollow noopener noreferrer"&gt;Grid&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 和 &lt;a href="https://developer.apple.com/documentation/swiftui/gridrow" target="_blank" rel="external nofollow noopener noreferrer"&gt;GridRow&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 是 iOS 16/macOS 13 新出的功能，用于快速构建静态格子视图。&lt;/p&gt;</description></item><item><title>3.3 布局的调整</title><link>https://apolla.cc/posts/3.3-%E5%B8%83%E5%B1%80%E7%9A%84%E8%B0%83%E6%95%B4/</link><pubDate>Fri, 23 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.3-%E5%B8%83%E5%B1%80%E7%9A%84%E8%B0%83%E6%95%B4/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;调整视图布局的方法是多样的，本文主要介绍通过调整 view 的尺寸、位置以及对齐方式等来实现布局的基础调整，在实际开发中，需要选择合适的方法来实现不同的布局效果。除此以外，后面还会介绍自定义 layout 来实现更加高级和灵活地布局。&lt;/p&gt;&#10;&lt;h1 class="heading-element" id="尺寸"&gt;&lt;span&gt;尺寸&lt;/span&gt;&#10; &lt;a href="#%e5%b0%ba%e5%af%b8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="padding"&gt;&lt;span&gt;padding&lt;/span&gt;&#10; &lt;a href="#padding" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;SwiftUI 提供了多个 padding 方法，可以方便地调整视图各个方向上的内边距，从而影响布局和空间的分配。&lt;/p&gt;</description></item><item><title>3.2 堆叠（Stacks）</title><link>https://apolla.cc/posts/3.2-%E5%A0%86%E5%8F%A0stacks/</link><pubDate>Thu, 22 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.2-%E5%A0%86%E5%8F%A0stacks/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="hstackvstackzstack"&gt;&lt;span&gt;HStack、VStack、ZStack&lt;/span&gt;&#10; &lt;a href="#hstackvstackzstack" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/hstack" target="_blank" rel="external nofollow noopener noreferrer"&gt;HStack&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;、&lt;a href="https://developer.apple.com/documentation/swiftui/vstack" target="_blank" rel="external nofollow noopener noreferrer"&gt;VStack&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;、&lt;a href="https://developer.apple.com/documentation/swiftui/zstack" target="_blank" rel="external nofollow noopener noreferrer"&gt;ZStack&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 分别可以在三个线性轴 x、y、z 方向上组合视图。&lt;/p&gt;</description></item><item><title>3.1 SwiftUI 布局思想简介</title><link>https://apolla.cc/posts/3.1-swiftui-%E5%B8%83%E5%B1%80%E6%80%9D%E6%83%B3%E7%AE%80%E4%BB%8B/</link><pubDate>Wed, 21 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3.1-swiftui-%E5%B8%83%E5%B1%80%E6%80%9D%E6%83%B3%E7%AE%80%E4%BB%8B/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;SwiftUI 的布局过程大致如下：&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;父视图为子视图提供布局空间。&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;若指定了尺寸，父视图提供的布局空间就是指定的尺寸范围。&lt;/li&gt;&#10;&lt;li&gt;若没指定尺寸：&#10;&lt;ul&gt;&#10;&lt;li&gt;若父视图是无边界的，比如 Color 还有下面提到的 ScrollView，它的尺寸默认是无限大（这里的无限大指可以利用的一切空间，下同）。&lt;/li&gt;&#10;&lt;li&gt;若父视图是有边界的，比如 HStack、VStack 等，它的尺寸取决于子视图的尺寸。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;子视图根据自身内容计算尺寸，并将该信息提供给父视图。&lt;/p&gt;&#10;&lt;p&gt;SwiftUI 中的视图层级类似树状结构，对每个节点视图的 body 属性的计算是个递归的过程，终止条件是遇到 body 属性为 Never 的视图，它们又称为原始视图，是这颗树上的叶子结点。这里提到的父子关系并非绝对概念，子视图可能也作为其它视图的父视图，父子其实是个相对概念。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;父视图根据子视图提供的尺寸信息计算自身尺寸并对子视图进行布局。&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;若父视图指定了尺寸，则根据指定的尺寸对子视图进行布局。&lt;/li&gt;&#10;&lt;li&gt;若父视图没指定尺寸，则根据子视图提供的尺寸信息计算自身的尺寸并对子视图进行布局。父视图在计算自身尺寸时如果它本身就是无边界的，那么它的尺寸不受子视图的影响。&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;</description></item><item><title>2.6 视图生命周期方法</title><link>https://apolla.cc/posts/2.6-%E8%A7%86%E5%9B%BE%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%96%B9%E6%B3%95/</link><pubDate>Tue, 20 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.6-%E8%A7%86%E5%9B%BE%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E6%96%B9%E6%B3%95/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="onappear"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/view/onappear(perform:)" target="_blank" rel="external nofollow noopener noreferrer"&gt;onAppear&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#onappear" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;在视图即将出现时会触发 onAppear 方法。&lt;/p&gt;&#10;&lt;p&gt;&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt;&lt;/p&gt;</description></item><item><title>2.7 自定义视图</title><link>https://apolla.cc/posts/2.7-%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A7%86%E5%9B%BE/</link><pubDate>Tue, 20 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.7-%E8%87%AA%E5%AE%9A%E4%B9%89%E8%A7%86%E5%9B%BE/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="自定义-view"&gt;&lt;span&gt;自定义 view&lt;/span&gt;&#10; &lt;a href="#%e8%87%aa%e5%ae%9a%e4%b9%89-view" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;SwiftUI 中的视图都是实现 View 协议的结构体，比如需要自定义一个垂直布局的 Label：&lt;/p&gt;</description></item><item><title>2.4.5 控件-样式</title><link>https://apolla.cc/posts/2.4.5-%E6%8E%A7%E4%BB%B6-%E6%A0%B7%E5%BC%8F/</link><pubDate>Mon, 19 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.4.5-%E6%8E%A7%E4%BB%B6-%E6%A0%B7%E5%BC%8F/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="色调"&gt;&lt;span&gt;色调&lt;/span&gt;&#10; &lt;a href="#%e8%89%b2%e8%b0%83" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;在 《控件-指示器》 一文提到过可以通过 &lt;code&gt;.tint&lt;/code&gt; 方法覆盖程序设置的 accentColor 来给控件指定主色调，但并非所有控件都能生效，比如使用渐变色样式时，无法应用该样式的控件会采用渐变色的第一个颜色进行渲染。&lt;/p&gt;</description></item><item><title>2.5 菜单与命令</title><link>https://apolla.cc/posts/2.5-%E8%8F%9C%E5%8D%95%E4%B8%8E%E5%91%BD%E4%BB%A4/</link><pubDate>Mon, 19 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.5-%E8%8F%9C%E5%8D%95%E4%B8%8E%E5%91%BD%E4%BB%A4/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;Menu 也是一种常用控件，用于创建菜单视图。Button、Toggle、Picker 等常用控件都可以作为 Menu 的子控件，Menu 本身还支持嵌套使用。&lt;/p&gt;&#10;&lt;p&gt;&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt;&lt;/p&gt;&#10;&lt;p&gt;Menu 的构建方法中有一个支持 primaryAction 的闭包，没有添加它时，单击 menu 就会弹出菜单，添加之后，单击 menu 的事件就会成为 primaryAction，长按（iOS）或者点击菜单下拉按钮（macOS）时才会弹出菜单。macOS 的下拉菜单按钮可以通过方法 &lt;a href="https://developer.apple.com/documentation/swiftui/view/menuindicator(_:)" target="_blank" rel="external nofollow noopener noreferrer"&gt;menuIndicator(_:)&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 隐藏。&lt;/p&gt;</description></item><item><title>2.4.4 控件-指示器</title><link>https://apolla.cc/posts/2.4.4-%E6%8E%A7%E4%BB%B6-%E6%8C%87%E7%A4%BA%E5%99%A8/</link><pubDate>Fri, 16 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.4.4-%E6%8E%A7%E4%BB%B6-%E6%8C%87%E7%A4%BA%E5%99%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="progressview"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/progressview" target="_blank" rel="external nofollow noopener noreferrer"&gt;ProgressView&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#progressview" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;ProgressView 有菊花和进度条两种样式，&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt; 。&lt;/p&gt;</description></item><item><title>2.4.1 控件-按钮</title><link>https://apolla.cc/posts/2.4.1-%E6%8E%A7%E4%BB%B6-%E6%8C%89%E9%92%AE/</link><pubDate>Thu, 15 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.4.1-%E6%8E%A7%E4%BB%B6-%E6%8C%89%E9%92%AE/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="按钮样式"&gt;&lt;span&gt;按钮样式&lt;/span&gt;&#10; &lt;a href="#%e6%8c%89%e9%92%ae%e6%a0%b7%e5%bc%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/button" target="_blank" rel="external nofollow noopener noreferrer"&gt;Button&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 可以通过字符串或 view 构建，需要注意的是，通过字符串构建 Button 时， &lt;code&gt;.frame&lt;/code&gt; 是无法扩大点击范围的。因为 frame 的作用是给父视图提供尺寸信息作布局用，我们可以在 frame 的基础上更改 button 的背景，但 button 自身的尺寸依然是由自身内容（字符串）决定的。对于简单的按钮可以直接通过字符串构建，系统也提供了内置的按钮样式。如需更丰富的样式，推荐使用 view 构建，或是自定义按钮样式。&lt;/p&gt;</description></item><item><title>2.4.2 控件-链接</title><link>https://apolla.cc/posts/2.4.2-%E6%8E%A7%E4%BB%B6-%E9%93%BE%E6%8E%A5/</link><pubDate>Thu, 15 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.4.2-%E6%8E%A7%E4%BB%B6-%E9%93%BE%E6%8E%A5/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="link"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/link" target="_blank" rel="external nofollow noopener noreferrer"&gt;Link&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#link" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;Link 可以打开网页链接，如果通用链接（Universal Link）支持，会跳转到对应的 App 页面。&lt;/p&gt;</description></item><item><title>2.4.3 控件-选择器</title><link>https://apolla.cc/posts/2.4.3-%E6%8E%A7%E4%BB%B6-%E9%80%89%E6%8B%A9%E5%99%A8/</link><pubDate>Thu, 15 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.4.3-%E6%8E%A7%E4%BB%B6-%E9%80%89%E6%8B%A9%E5%99%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="toggle"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/toggle" target="_blank" rel="external nofollow noopener noreferrer"&gt;Toggle&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#toggle" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;Toggle 是表示开关状态的控件，默认的颜色风格是绿色，使用 &lt;code&gt;.tint&lt;/code&gt; 可以改变颜色。&lt;/p&gt;</description></item><item><title>2.1.1 文本-Text</title><link>https://apolla.cc/posts/2.1.1-%E6%96%87%E6%9C%AC-text/</link><pubDate>Mon, 05 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.1.1-%E6%96%87%E6%9C%AC-text/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="字符串"&gt;&lt;span&gt;字符串&lt;/span&gt;&#10; &lt;a href="#%e5%ad%97%e7%ac%a6%e4%b8%b2" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;SwiftUI 中涉及到字符串的地方，基本都支持普通的字符串和本地化字符串。&lt;/p&gt;</description></item><item><title>2.1.2 文本-Label</title><link>https://apolla.cc/posts/2.1.2-%E6%96%87%E6%9C%AC-label/</link><pubDate>Mon, 05 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.1.2-%E6%96%87%E6%9C%AC-label/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="构建方法"&gt;&lt;span&gt;构建方法&lt;/span&gt;&#10; &lt;a href="#%e6%9e%84%e5%bb%ba%e6%96%b9%e6%b3%95" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/label" target="_blank" rel="external nofollow noopener noreferrer"&gt;Label&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 可以快速生成图片和文字的组合，默认布局是左图右文。&lt;/p&gt;</description></item><item><title>2.1.3 文本-输入</title><link>https://apolla.cc/posts/2.1.3-%E6%96%87%E6%9C%AC-%E8%BE%93%E5%85%A5/</link><pubDate>Mon, 05 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2.1.3-%E6%96%87%E6%9C%AC-%E8%BE%93%E5%85%A5/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="textfield"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/textfield" target="_blank" rel="external nofollow noopener noreferrer"&gt;TextField&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#textfield" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="构建及样式"&gt;&lt;span&gt;构建及样式&lt;/span&gt;&#10; &lt;a href="#%e6%9e%84%e5%bb%ba%e5%8f%8a%e6%a0%b7%e5%bc%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;TextField 具有多个构建方法，最简单的如下：&lt;/p&gt;</description></item><item><title>1.3.4 工具栏（Toolbars）</title><link>https://apolla.cc/posts/1.3.4-%E5%B7%A5%E5%85%B7%E6%A0%8Ftoolbars/</link><pubDate>Thu, 01 Dec 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3.4-%E5%B7%A5%E5%85%B7%E6%A0%8Ftoolbars/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;SwiftUI 将 navigationBar、bottomBar、tabBar、windowToolbar 等视图的功能和样式都整合在了工具栏中，使用时调用的 api 都是以 .toolbar 开头的。&lt;/p&gt;&#10;&lt;p&gt;比如要给导航栏右侧添加一个分享按钮：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;#if os(iOS)&#10;NavigationStack {&#10; ContentView()&#10; .toolbar {&#10; ToolbarItem(placement: .navigationBarTrailing) {&#10; Button {&#10; } label: {&#10; Image(systemName: &amp;#34;square.and.arrow.up&amp;#34;)&#10; }&#10; }&#10; }&#10;}&#10;#endif&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="background: #007BFF; color: white; padding: 3px 10px; border-radius: 5px"&gt;&amp;gt; 查看示例&lt;/span&gt;&lt;/p&gt;</description></item><item><title>1.3.0 TabView 的使用</title><link>https://apolla.cc/posts/1.3.0-tabview-%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Wed, 23 Nov 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3.0-tabview-%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="基础使用"&gt;&lt;span&gt;基础使用&lt;/span&gt;&#10; &lt;a href="#%e5%9f%ba%e7%a1%80%e4%bd%bf%e7%94%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/tabview" target="_blank" rel="external nofollow noopener noreferrer"&gt;TabView&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 等同于 UIKit 中的 UITabBar，先来看看它的基础使用：&lt;/p&gt;</description></item><item><title>1.3.2 导航之 NavigationSplitView</title><link>https://apolla.cc/posts/1.3.2-%E5%AF%BC%E8%88%AA%E4%B9%8B-navigationsplitview/</link><pubDate>Mon, 21 Nov 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3.2-%E5%AF%BC%E8%88%AA%E4%B9%8B-navigationsplitview/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/navigationsplitview" target="_blank" rel="external nofollow noopener noreferrer"&gt;NavigationSplitView&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 用于快速构建多栏视图，它支持在 Apple 全平台上使用。根据设备屏幕尺寸（Size Class）的差异，NavigationSplitView 的样式有所不同。&lt;/p&gt;&#10;&lt;p&gt;Size Class 分为 regular 和 compact，NavigationSplitView 相应的表现分别是分栏和导航栈。正如示例所示，在 iPhone 14 Plus 或 iPhone 14 Pro Max 机型上，竖屏时 Size Class 是 compact，导航行为就是常见的 push 和 pop。而横屏时，Size Class 是 regular，视图会变成分栏样式。&lt;/p&gt;</description></item><item><title>1.3.1 导航之 NavigationStack</title><link>https://apolla.cc/posts/1.3.1-%E5%AF%BC%E8%88%AA%E4%B9%8B-navigationstack/</link><pubDate>Mon, 05 Sep 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3.1-%E5%AF%BC%E8%88%AA%E4%B9%8B-navigationstack/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;iOS 16 废弃了 NavigationView，使用更加灵活的 &lt;a href="https://developer.apple.com/documentation/swiftui/navigationstack" target="_blank" rel="external nofollow noopener noreferrer"&gt;NavigationStack&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;、&lt;a href="https://developer.apple.com/documentation/swiftui/navigationsplitview" target="_blank" rel="external nofollow noopener noreferrer"&gt;NavigationSplitView&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 管理导航栈。二者在 iOS、iPadOS、macOS 上均可使用，但在不同平台表现不一。后文主要演示 NavigationStack 在 iPhone、iPad 上的使用，NavigationSplitView 在 iPad、Mac 上的使用。&lt;/p&gt;</description></item><item><title>1.3 SwiftUI 中的场景</title><link>https://apolla.cc/posts/1.3-swiftui-%E4%B8%AD%E7%9A%84%E5%9C%BA%E6%99%AF/</link><pubDate>Mon, 29 Aug 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.3-swiftui-%E4%B8%AD%E7%9A%84%E5%9C%BA%E6%99%AF/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;p&gt;&lt;em&gt;鉴于 Scene 比较特殊，难以在 Eul 中内置示例，笔者为其单独创建了一个样例工程，源码：&lt;a href="https://github.com/zzzwco/resources/tree/main/eul/SampleScene" target="_blank" rel="external nofollow noopener noreferrer"&gt;Eul/SampleScene&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;。&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;在 [[1.1.2 生命周期的演变]]中已经介绍过一些关于场景的概念了，下面逐一介绍 SwiftUI 内置的场景及其用法。&lt;/p&gt;&#10;&lt;h2 class="heading-element" id="windowgroup"&gt;&lt;span&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/windowgroup?changes=latest_minor" target="_blank" rel="external nofollow noopener noreferrer"&gt;WindowGroup&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#windowgroup" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;这是最重要、最常用的场景，新建一个 SwiftUI 工程时，在 app 入口处就会看到如下代码：&lt;/p&gt;</description></item><item><title>1.2 生命周期的演变</title><link>https://apolla.cc/posts/1.2-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%9A%84%E6%BC%94%E5%8F%98/</link><pubDate>Sat, 20 Aug 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.2-%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%9A%84%E6%BC%94%E5%8F%98/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;iOS 13 之前，app 的入口以及生命周期方法由 &lt;a href="https://developer.apple.com/documentation/uikit/uiapplicationdelegate" target="_blank" rel="external nofollow noopener noreferrer"&gt;UIApplicationDelegate&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 协议定义，通常我们使用 &lt;a href="https://developer.apple.com/documentation/uikit/uiwindow" target="_blank" rel="external nofollow noopener noreferrer"&gt;UIWindow&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 实例作为呈现界面和分发事件的窗口。&lt;/p&gt;&#10;&lt;p&gt;iOS 13 开始，iPad 支持多窗口模式。 臃肿的 AppDelegate 不堪重负，于是它将各个窗口的管理工作分配给 &lt;a href="https://developer.apple.com/documentation/uikit/uiscenedelegate" target="_blank" rel="external nofollow noopener noreferrer"&gt;UISceneDelegate&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 实例。&lt;/p&gt;&#10;&lt;p&gt;iOS 14 新增了 SwiftUI 专属的 &lt;a href="https://developer.apple.com/documentation/swiftui/app" target="_blank" rel="external nofollow noopener noreferrer"&gt;App&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 协议，它定义了 app 的结构和行为。创建一个 SwiftUI 项目时，Xcode 默认实现了一个 App 实例：&lt;/p&gt;</description></item><item><title>1.1 App 入口与配置</title><link>https://apolla.cc/posts/1.1-app-%E5%85%A5%E5%8F%A3%E4%B8%8E%E9%85%8D%E7%BD%AE/</link><pubDate>Mon, 15 Aug 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.1-app-%E5%85%A5%E5%8F%A3%E4%B8%8E%E9%85%8D%E7%BD%AE/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="入口"&gt;&lt;span&gt;入口&lt;/span&gt;&#10; &lt;a href="#%e5%85%a5%e5%8f%a3" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;当我们 &lt;a href="https://developer.apple.com/documentation/xcode/creating-an-xcode-project-for-an-app" target="_blank" rel="external nofollow noopener noreferrer"&gt;创建一个工程&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 后，首先看到的就是如下代码：&lt;/p&gt;</description></item><item><title>1.1 App 入口与配置_副本</title><link>https://apolla.cc/posts/1.1-app-%E5%85%A5%E5%8F%A3%E4%B8%8E%E9%85%8D%E7%BD%AE_%E5%89%AF%E6%9C%AC/</link><pubDate>Mon, 15 Aug 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1.1-app-%E5%85%A5%E5%8F%A3%E4%B8%8E%E9%85%8D%E7%BD%AE_%E5%89%AF%E6%9C%AC/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="入口"&gt;&lt;span&gt;入口&lt;/span&gt;&#10; &lt;a href="#%e5%85%a5%e5%8f%a3" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;当我们 &lt;a href="https://developer.apple.com/documentation/xcode/creating-an-xcode-project-for-an-app" target="_blank" rel="external nofollow noopener noreferrer"&gt;创建一个工程&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 后，首先看到的就是如下代码：&lt;/p&gt;</description></item><item><title>1.1 Swift 并发新体验</title><link>https://apolla.cc/posts/1.1-swift-%E5%B9%B6%E5%8F%91%E6%96%B0%E4%BD%93%E9%AA%8C/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/1.1-swift-%E5%B9%B6%E5%8F%91%E6%96%B0%E4%BD%93%E9%AA%8C/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="引言"&gt;&lt;span&gt;引言&lt;/span&gt;&#10; &lt;a href="#%e5%bc%95%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;对于诞生于 2014 年的 Swift 而言，它已不再年轻。至今我还记得初次体验 Swift 时的喜悦之情，比起冗长的 OC 而言，它更加现代、简洁、优雅。但 Swift 的前期发展是野蛮而动荡的，每次发布新版本时都会导致旧项目出现大量的报错和告警，项目迁移工作令开发者苦不堪言。不得不说，Swift 诞生之初就敢于在项目中实践并运用的人，是真的猛士。我是从 Swift 4 才开始将项目逐渐从 OC 向 Swift 迁移的，到 2019 年 Swift 5 实现了 ABI 稳定时，才全面迁移至纯 Swift 开发。&lt;/p&gt;</description></item><item><title>1.2 async、await 的使用</title><link>https://apolla.cc/posts/1.2-asyncawait-%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/1.2-asyncawait-%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="asyncawait"&gt;&lt;span&gt;async/await&lt;/span&gt;&#10; &lt;a href="#asyncawait" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;上一节我们已经简单介绍了 async/await 的使用，接下来我们通过一个例子来加深对 async/await 的理解。如下是一个下载图片并展示在界面上的示例代码：&lt;/p&gt;</description></item><item><title>1.3 SwiftUI 中常见的异步 API</title><link>https://apolla.cc/posts/1.3-swiftui-%E4%B8%AD%E5%B8%B8%E8%A7%81%E7%9A%84%E5%BC%82%E6%AD%A5-api/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/1.3-swiftui-%E4%B8%AD%E5%B8%B8%E8%A7%81%E7%9A%84%E5%BC%82%E6%AD%A5-api/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="task"&gt;&lt;span&gt;.task&lt;/span&gt;&#10; &lt;a href="#task" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;SwiftUI 刚发布时，View 只有两个最基础的生命周期方法：&lt;code&gt;.onAppear&lt;/code&gt; 和 &lt;code&gt;.onDisAppear&lt;/code&gt;，iOS 14 又新增了 &lt;code&gt;.onChange&lt;/code&gt; 这样的修饰器，可以监听值的变化。不过上面的几个 API 都是在主线程调用的，iOS 15 新增的 &lt;code&gt;.task&lt;/code&gt; 修饰器赋予了 View 快速开启异步任务的能力。&lt;/p&gt;</description></item><item><title>2.1 任务</title><link>https://apolla.cc/posts/2.1-%E4%BB%BB%E5%8A%A1/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.1-%E4%BB%BB%E5%8A%A1/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="任务的创建"&gt;&lt;span&gt;任务的创建&lt;/span&gt;&#10; &lt;a href="#%e4%bb%bb%e5%8a%a1%e7%9a%84%e5%88%9b%e5%bb%ba" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;在前面的章节中，我们已经使用过 &lt;code&gt;Task&lt;/code&gt; 了，比如在同步环境 &lt;code&gt;viewDidLoad&lt;/code&gt; 方法中开启异步环境，或者使用 View 的 &lt;code&gt;.task&lt;/code&gt; 修饰器开启异步任务。还有 &lt;code&gt;async let&lt;/code&gt; 这样的语法糖，也会隐式地创建 task，方便我们写出简洁、安全的并发代码。&lt;/p&gt;</description></item><item><title>2.2 任务组</title><link>https://apolla.cc/posts/2.2-%E4%BB%BB%E5%8A%A1%E7%BB%84/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.2-%E4%BB%BB%E5%8A%A1%E7%BB%84/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="任务组的创建"&gt;&lt;span&gt;任务组的创建&lt;/span&gt;&#10; &lt;a href="#%e4%bb%bb%e5%8a%a1%e7%bb%84%e7%9a%84%e5%88%9b%e5%bb%ba" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;code&gt;async let&lt;/code&gt; 和 &lt;code&gt;Task&lt;/code&gt; 能够满足我们大多数的并发需求，但在某些更复杂的需求场景下，它们力所不及。比如这样的需求：我们先发起一个网络请求，拉取所有要下载的书籍并展示在列表上。然后，我们要实现“下载全部”的功能。&lt;/p&gt;</description></item><item><title>2.3 小结</title><link>https://apolla.cc/posts/2.3-%E5%B0%8F%E7%BB%93/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.3-%E5%B0%8F%E7%BB%93/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;前面的章节中，我们学习了 &lt;code&gt;async let&lt;/code&gt;、&lt;code&gt;Task&lt;/code&gt; 以及 &lt;code&gt;TaskGroup&lt;/code&gt; 的使用。它们都可以帮助我们写出高质量的并发代码，也各有千秋。&lt;/p&gt;&#10;&lt;p&gt;借助于 &lt;code&gt;async let&lt;/code&gt; 这个语法糖，我们能够在不直接接触 &lt;code&gt;Task&lt;/code&gt; 或 &lt;code&gt;TaskGroup&lt;/code&gt; 的层面上开启异步任务，获取异步返回结果，因此 &lt;code&gt;async let&lt;/code&gt; 又叫“并发绑定”，顾名思义，为某个变量绑定了并发任务的异步返回结果。&lt;/p&gt;</description></item><item><title>3.1 异步序列</title><link>https://apolla.cc/posts/3.1-%E5%BC%82%E6%AD%A5%E5%BA%8F%E5%88%97/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/3.1-%E5%BC%82%E6%AD%A5%E5%BA%8F%E5%88%97/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="asyncsequence-简介"&gt;&lt;span&gt;AsyncSequence 简介&lt;/span&gt;&#10; &lt;a href="#asyncsequence-%e7%ae%80%e4%bb%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swift/asyncsequence" target="_blank" rel="external nofollow noopener noreferrer"&gt;AsyncSequence&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 是一个支持异步迭代的协议，它和 &lt;a href="https://developer.apple.com/documentation/swift/sequence" target="_blank" rel="external nofollow noopener noreferrer"&gt;Sequence&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 非常类似，同样支持使用 &lt;code&gt;for&lt;/code&gt;、&lt;code&gt;while&lt;/code&gt;、&lt;code&gt;repeat&lt;/code&gt; 循环访问子元素，也支持使用 &lt;code&gt;map&lt;/code&gt;、&lt;code&gt;filter&lt;/code&gt;、&lt;code&gt;reduce&lt;/code&gt; 等高阶函数，只不过这些操作都是异步的。&lt;/p&gt;</description></item><item><title>3.2 异步流</title><link>https://apolla.cc/posts/3.2-%E5%BC%82%E6%AD%A5%E6%B5%81/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/3.2-%E5%BC%82%E6%AD%A5%E6%B5%81/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="asyncstream-的使用"&gt;&lt;span&gt;AsyncStream 的使用&lt;/span&gt;&#10; &lt;a href="#asyncstream-%e7%9a%84%e4%bd%bf%e7%94%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/swift/asyncstream" target="_blank" rel="external nofollow noopener noreferrer"&gt;AsyncStream&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt; 是一个遵循 &lt;code&gt;AsyncSequence&lt;/code&gt; 协议的结构体，借助于它，我们无需手动实现异步迭代器，就可以方便地构建异步序列。相比 &lt;code&gt;AsyncSequence&lt;/code&gt; ，它是一个实现异步序列的轻量级方案。&lt;/p&gt;</description></item><item><title>4.1 actor 的使用</title><link>https://apolla.cc/posts/4.1-actor-%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/4.1-actor-%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="actor-并发模型"&gt;&lt;span&gt;Actor 并发模型&lt;/span&gt;&#10; &lt;a href="#actor-%e5%b9%b6%e5%8f%91%e6%a8%a1%e5%9e%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/actor.png' alt="/images/actor.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;actor 并发模型首次发表于 1973 年，是一个用于并发计算的数学模型。&lt;/p&gt;</description></item><item><title>4.2 @globalActor、@MainActor 的使用</title><link>https://apolla.cc/posts/4.2-@globalactor@mainactor-%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/4.2-@globalactor@mainactor-%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="globalactor"&gt;&lt;span&gt;GlobalActor&lt;/span&gt;&#10; &lt;a href="#globalactor" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;状态隔离使得 actor 成为在并发环境中安全使用的引用类型，但它的作用范围仅限于单个 actor 类型。如果某些变量、函数分散在不同的地方，actor 无法将它们置于同一个隔离环境中。因此，Swift 引入了 &lt;a href="https://developer.apple.com/documentation/swift/globalactor" target="_blank" rel="external nofollow noopener noreferrer"&gt;GlobalActor 协议&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;，将状态隔离的概念扩展至全局范围。&lt;/p&gt;</description></item><item><title>流程控制</title><link>https://apolla.cc/posts/%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6/</link><pubDate>Mon, 08 Apr 2024 15:42:27 +0800</pubDate><guid>https://apolla.cc/posts/%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="条件控制"&gt;&lt;span&gt;条件控制&lt;/span&gt;&#10; &lt;a href="#%e6%9d%a1%e4%bb%b6%e6%8e%a7%e5%88%b6" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;h3 class="heading-element" id="if-else"&gt;&lt;span&gt;if-else&lt;/span&gt;&#10; &lt;a href="#if-else" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;h3 class="heading-element" id="区别"&gt;&lt;span&gt;区别&lt;/span&gt;&#10; &lt;a href="#%e5%8c%ba%e5%88%ab" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;ol&gt;&#10;&lt;li&gt;if后面的条件的小括号可以省略&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;pre&gt;&lt;code&gt;if age &amp;gt; 22 {&#10;    print(&amp;#34;age &amp;gt; 22&amp;#34;)&#10;}else{&#10;    print(&amp;#34;age &amp;lt;= 22&amp;#34;)&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="while"&gt;&lt;span&gt;while&lt;/span&gt;&#10; &lt;a href="#while" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;var n = 10&#10;&#10;while n &amp;gt; 0 {&#10;&#10;    print(&amp;#34;n == \(n)&amp;#34;)&#10;&#10;    n -= 1&#10;&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="repeat-while"&gt;&lt;span&gt;repeat-while&lt;/span&gt;&#10; &lt;a href="#repeat-while" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;blockquote&gt;&#10;&lt;p&gt;相当于do-while&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>4.3 Operators 使用手册（三）</title><link>https://apolla.cc/posts/4.3-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%B8%89/</link><pubDate>Fri, 19 Apr 2024 15:20:06 +0800</pubDate><guid>https://apolla.cc/posts/4.3-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%B8%89/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="republish"&gt;&lt;span&gt;Republish&lt;/span&gt;&#10; &lt;a href="#republish" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="switchtolatest"&gt;&lt;span&gt;switchToLatest&lt;/span&gt;&#10; &lt;a href="#switchtolatest" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;字面意思就是切换到最近的 publisher，这比较难那理解，我们结合代码来看。&lt;/p&gt;</description></item><item><title>1.1 Combine 概览</title><link>https://apolla.cc/posts/1.1-combine-%E6%A6%82%E8%A7%88/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/1.1-combine-%E6%A6%82%E8%A7%88/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;WWDC 2019 上与声明式框架 SwiftUI 一同发布的，还有同等重要的响应式框架 Combine，它用于处理（异步）事件和数据流。随着 Concurrency 框架的发布和 SwiftUI 的不断完善，可能在实际开发中 Combine 直接露面的概率会越来越小。但它是 SwiftUI 简洁高效的基石，了解它有助于更好地理解和使用 SwiftUI。&lt;/p&gt;&#10;&lt;p&gt;Combine 框架包含三个核心概念：Publisher、Subscriber、Operator。&lt;/p&gt;</description></item><item><title>2.1 Publisher 的基本使用（一）</title><link>https://apolla.cc/posts/2.1-publisher-%E7%9A%84%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8%E4%B8%80/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.1-publisher-%E7%9A%84%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8%E4%B8%80/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;在前面的章节中，实际上我们已经多次使用过 Publisher，只是我们不曾察觉。比如我们之前使用的 ObservedObject，它的定义如下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;@propertyWrapper @frozen struct ObservedObject&amp;lt;ObjectType&amp;gt; where ObjectType : ObservableObject&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;其中的泛型 ObjectType 遵循 &lt;strong&gt;ObservableObject&lt;/strong&gt; 协议，该协议的定义中只有一个属性：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;// A publisher that emits before the object has changed.&#10;var objectWillChange: Self.ObjectWillChangePublisher&#10;&#10;// The type of publisher that emits before the object has changed.&#10;associatedtype ObjectWillChangePublisher : Publisher = ObservableObjectPublisher&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;其中的关联类型 ObjectWillChangePublisher 正是遵循 &lt;strong&gt;Publisher&lt;/strong&gt; 协议。也就是说，当我们使用 ObservedObject 时，系统会隐式地生成 objectWillChange 这样一个 Publisher，一旦遵循 ObservableObject 的 class 中标记为 @Published 的属性值发生变化，就会通过该 Publisher 告知相关的对象。&lt;/p&gt;</description></item><item><title>2.2 Publisher 的基本使用（二）</title><link>https://apolla.cc/posts/2.2-publisher-%E7%9A%84%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8%E4%BA%8C/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.2-publisher-%E7%9A%84%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8%E4%BA%8C/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="anypublisher"&gt;&lt;span&gt;AnyPublisher&lt;/span&gt;&#10; &lt;a href="#anypublisher" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;前面视图部分的内容我们提到过，有些情况下， View 为了避免在传参或返回时类型不一致从而无法通过编译时，可以使用 AnyView 来作类型擦除，以此使得视图变得通用。&lt;/p&gt;</description></item><item><title>2.3 特殊的 Publisher：Subject</title><link>https://apolla.cc/posts/2.3-%E7%89%B9%E6%AE%8A%E7%9A%84-publishersubject/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/2.3-%E7%89%B9%E6%AE%8A%E7%9A%84-publishersubject/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;Subject 协议继承自 Publisher 协议，遵循 Subject 协议的 Publisher 是一种特定类型的 Publisher，它有如下方法：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;/** Subject 协议方法 */&#10;&#10;/** 向订阅者发送数据 */&#10;// 发送指定值&#10;func send(Self.Output)&#10;// 发送空值（此时 Output 类型为 Void）&#10;func send()&#10;&#10;/** 向订阅者发送生命周期事件 */&#10;// 发送 subscription 实例&#10;func send(subscription: Subscription)&#10;&#10;// 发送 completion 信号&#10;func send(completion: Subscribers.Completion&amp;lt;Self.Failure&amp;gt;)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Subject 的特别之处在于，我们可以手动调用 send 方法向数据流注入新的值。&lt;/p&gt;</description></item><item><title>3.1 Subscriber 的详细介绍</title><link>https://apolla.cc/posts/3.1-subscriber-%E7%9A%84%E8%AF%A6%E7%BB%86%E4%BB%8B%E7%BB%8D/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/3.1-subscriber-%E7%9A%84%E8%AF%A6%E7%BB%86%E4%BB%8B%E7%BB%8D/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="订阅行为的详细过程"&gt;&lt;span&gt;订阅行为的详细过程&lt;/span&gt;&#10; &lt;a href="#%e8%ae%a2%e9%98%85%e8%a1%8c%e4%b8%ba%e7%9a%84%e8%af%a6%e7%bb%86%e8%bf%87%e7%a8%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;前面我们介绍过了，&lt;strong&gt;Subscriber&lt;/strong&gt; 是一个协议，和 Publisher 遥相呼应，前者接收数据（Input、Failure），后者发送数据（Output、Failure)，数据类型必须保持一致。&lt;/p&gt;</description></item><item><title>3.2 内建 Subscriber 的使用</title><link>https://apolla.cc/posts/3.2-%E5%86%85%E5%BB%BA-subscriber-%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/3.2-%E5%86%85%E5%BB%BA-subscriber-%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;Combine 内建了两个 Subscriber：sink、assign，SwiftUI 框架中有一个内建的 Subscriber：onReceive。&lt;/p&gt;&#10;&lt;h1 class="heading-element" id="sink"&gt;&lt;span&gt;sink&lt;/span&gt;&#10; &lt;a href="#sink" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;关于 sink，前面我们已经介绍过了。这里只做复习：它的作用是生成订阅者来接收发布者发送的数据，该订阅者在 receiveCompletion 闭包中返回事件结束的消息，在 receiveValue 闭包中返回接收到的数据值。&lt;/p&gt;</description></item><item><title>4.1 Operators 使用手册（一）</title><link>https://apolla.cc/posts/4.1-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%B8%80/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/4.1-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%B8%80/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;p&gt;我们可以在数据流的管道中，使用 Operators 对上游的数据进行各种操作，然后再发送给下游的订阅者，这就是 Operators 的作用。&lt;/p&gt;&#10;&lt;p&gt;Combine 提供了大量的 Operators 给我们使用，鉴于内容过多，笔者将其分为三个小节。&lt;/p&gt;&#10;&lt;p&gt;后续内容用了部分&lt;strong&gt;弹珠图&lt;/strong&gt;来加深理解，有兴趣的读者可以进一步了解：&lt;a href="https://rx-marbles-online.herokuapp.com/" target="_blank" rel="external nofollow noopener noreferrer"&gt;Marble Diagrams&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;。&lt;/p&gt;</description></item><item><title>4.2 Operators 使用手册（二）</title><link>https://apolla.cc/posts/4.2-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%BA%8C/</link><pubDate>Fri, 19 Apr 2024 15:20:05 +0800</pubDate><guid>https://apolla.cc/posts/4.2-operators-%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C%E4%BA%8C/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;h1 class="heading-element" id="mathematic"&gt;&lt;span&gt;Mathematic&lt;/span&gt;&#10; &lt;a href="#mathematic" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="maxtrymax"&gt;&lt;span&gt;max、tryMax&lt;/span&gt;&#10; &lt;a href="#maxtrymax" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/max.png' alt="/images/max.png"&gt;&lt;/p&gt;</description></item><item><title>函数</title><link>https://apolla.cc/posts/%E5%87%BD%E6%95%B0/</link><pubDate>Mon, 08 Apr 2024 17:57:25 +0800</pubDate><guid>https://apolla.cc/posts/%E5%87%BD%E6%95%B0/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="函数定义"&gt;&lt;span&gt;函数定义&lt;/span&gt;&#10; &lt;a href="#%e5%87%bd%e6%95%b0%e5%ae%9a%e4%b9%89" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;pre&gt;&lt;code&gt;//有返回值&#10;func sum(v1: Int, v2: Int) -&amp;gt; Int {&#10;    return v1 &amp;#43; v2&#10;}&#10;sum(v1: 10, v2: 20)&#10;&#10;//无返回值&#10;func sayHello(){&#10;    print(&amp;#34;Hello&amp;#34;)&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&#10;&lt;p&gt;形参默认是let 也只能是let&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>5 Swift 5.9 新特性</title><link>https://apolla.cc/posts/5-swift-5.9-%E6%96%B0%E7%89%B9%E6%80%A7/</link><pubDate>Fri, 19 Apr 2024 15:20:06 +0800</pubDate><guid>https://apolla.cc/posts/5-swift-5.9-%E6%96%B0%E7%89%B9%E6%80%A7/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;注：Swift 5.9 目前并未正式发布，本文会在正式发布后再次更新。&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h1 class="heading-element" id="if-和-switch-表达式se-0380"&gt;&lt;span&gt;if 和 switch 表达式（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0380&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#if-%e5%92%8c-switch-%e8%a1%a8%e8%be%be%e5%bc%8fse-0380" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;pre&gt;&lt;code&gt;let s1 = if Bool.random() { &amp;#34;YES&amp;#34; } else { &amp;#34;NO&amp;#34; }&#10;&#10;let s2 = switch Bool.random() {&#10;case true: &amp;#34;YES&amp;#34;&#10;case false: &amp;#34;NO&amp;#34;&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h1 class="heading-element" id="值和类型参数包se-0393"&gt;&lt;span&gt;值和类型参数包（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0393&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#%e5%80%bc%e5%92%8c%e7%b1%bb%e5%9e%8b%e5%8f%82%e6%95%b0%e5%8c%85se-0393" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;值和类型参数，实现了对不同类型的值和类型的抽象化，这是在 Swift 中实现可变泛型的第一步。&lt;/p&gt;</description></item><item><title>枚举</title><link>https://apolla.cc/posts/%E6%9E%9A%E4%B8%BE/</link><pubDate>Tue, 09 Apr 2024 14:42:34 +0800</pubDate><guid>https://apolla.cc/posts/%E6%9E%9A%E4%B8%BE/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="常规用法"&gt;&lt;span&gt;常规用法&lt;/span&gt;&#10; &lt;a href="#%e5%b8%b8%e8%a7%84%e7%94%a8%e6%b3%95" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;pre&gt;&lt;code&gt;enum accountType {&#10;    case email&#10;    case phone&#10;}&#10;accountType.email&#10;accountType.phone&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="关联值"&gt;&lt;span&gt;关联值&lt;/span&gt;&#10; &lt;a href="#%e5%85%b3%e8%81%94%e5%80%bc" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;blockquote&gt;&#10;&lt;p&gt;有时将枚举的成员值跟其他类型的值关联存储在一起，会非常有用&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>4 Swift 5.8 新特性</title><link>https://apolla.cc/posts/4-swift-5.8-%E6%96%B0%E7%89%B9%E6%80%A7/</link><pubDate>Fri, 31 Mar 2023 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/4-swift-5.8-%E6%96%B0%E7%89%B9%E6%80%A7/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="闭包内隐式调用-selfse-0365"&gt;&lt;span&gt;闭包内隐式调用 self（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0365&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#%e9%97%ad%e5%8c%85%e5%86%85%e9%9a%90%e5%bc%8f%e8%b0%83%e7%94%a8-selfse-0365" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;pre&gt;&lt;code&gt;class Timer {&#10; var eventHandler: (() -&amp;gt; Void)?&#10; &#10; func start() {&#10; DispatchQueue.main.asyncAfter(deadline: .now() &amp;#43; 5) {&#10; self.eventHandler?()&#10; }&#10; }&#10;}&#10;&#10;class ViewController {&#10; let timer = Timer()&#10; &#10; init() {&#10; timer.eventHandler = { [weak self] in&#10; guard let self else { return }&#10; // 如果已使用 [weak self] 捕获了 self 并且解包&#10; // 则无需显式调用 self&#10; doSomething()&#10; }&#10; timer.start()&#10; }&#10; &#10; func doSomething() {&#10; print(&amp;#34;Doing something...&amp;#34;)&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h1 class="heading-element" id="集合类型支持向下类型转换"&gt;&lt;span&gt;集合类型支持向下类型转换&lt;/span&gt;&#10; &lt;a href="#%e9%9b%86%e5%90%88%e7%b1%bb%e5%9e%8b%e6%94%af%e6%8c%81%e5%90%91%e4%b8%8b%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;pre&gt;&lt;code&gt;class A {}&#10;class A1: A {}&#10;class A2: A {}&#10;&#10;func downcast(arr: [A]) {&#10; switch arr {&#10; case let a1 as [A1]:&#10; print(&amp;#34;arr is [A1]: \(a1)&amp;#34;)&#10; case let a2 as [A2]:&#10; print(&amp;#34;arr is [A2]: \(a2)&amp;#34;)&#10; default:&#10; print(&amp;#34;Unknown collection type&amp;#34;)&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Swift 5.8 以前，以上的代码无法通过编译。需要这样写才可以：&lt;/p&gt;</description></item><item><title>3 Swift 中的 Result builders</title><link>https://apolla.cc/posts/3-swift-%E4%B8%AD%E7%9A%84-result-builders/</link><pubDate>Tue, 30 Aug 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/3-swift-%E4%B8%AD%E7%9A%84-result-builders/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;br&gt;&#10;&lt;p&gt;在以往的命令式编程中，通常这样构建视图：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;let label = UILabel()&#10;label.frame = self.view.bounds&#10;self.view.addSubview(label)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;但 SwiftUI 采用的是声明式语法：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;VStack {&#10; Text(&amp;#34;1&amp;#34;)&#10;&#9;List {&#10; Text(&amp;#34;&amp;#34;)&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;显而易见，SwiftUI 比 UIKit 要简洁地多，我们可以轻松地将不同的视图组合成复杂的界面。这得益于 Result builders（结果构造器），它使 SwiftUI 成为了特定领域语言（DSL）。&lt;/p&gt;</description></item><item><title>1 Swift 5.7 新特性</title><link>https://apolla.cc/posts/1-swift-5.7-%E6%96%B0%E7%89%B9%E6%80%A7/</link><pubDate>Fri, 15 Jul 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/1-swift-5.7-%E6%96%B0%E7%89%B9%E6%80%A7/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="简化的可选绑定se-0345"&gt;&lt;span&gt;简化的可选绑定（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0345&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#%e7%ae%80%e5%8c%96%e7%9a%84%e5%8f%af%e9%80%89%e7%bb%91%e5%ae%9ase-0345" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;对可选类型解包时无需显式绑定，写法更简洁：&lt;/p&gt;</description></item><item><title>2 Swift 中的不透明类型和存在类型</title><link>https://apolla.cc/posts/2-swift-%E4%B8%AD%E7%9A%84%E4%B8%8D%E9%80%8F%E6%98%8E%E7%B1%BB%E5%9E%8B%E5%92%8C%E5%AD%98%E5%9C%A8%E7%B1%BB%E5%9E%8B/</link><pubDate>Wed, 13 Jul 2022 08:00:00 +0800</pubDate><guid>https://apolla.cc/posts/2-swift-%E4%B8%AD%E7%9A%84%E4%B8%8D%E9%80%8F%E6%98%8E%E7%B1%BB%E5%9E%8B%E5%92%8C%E5%AD%98%E5%9C%A8%E7%B1%BB%E5%9E%8B/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;h1 class="heading-element" id="不透明类型some-关键字"&gt;&lt;span&gt;不透明类型、some 关键字&lt;/span&gt;&#10; &lt;a href="#%e4%b8%8d%e9%80%8f%e6%98%8e%e7%b1%bb%e5%9e%8bsome-%e5%85%b3%e9%94%ae%e5%ad%97" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;code&gt;some&lt;/code&gt; 关键字由 Swift 5.1 引入，它用来修饰某个协议，使之成为&lt;strong&gt;不透明类型&lt;/strong&gt;。&lt;/p&gt;</description></item><item><title>MemoryLayout</title><link>https://apolla.cc/posts/memorylayout/</link><pubDate>Tue, 09 Apr 2024 14:44:05 +0800</pubDate><guid>https://apolla.cc/posts/memorylayout/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;blockquote&gt;&#10;&lt;p&gt;可以使用MemoryLayout获取数据类型占用的内存大小&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;pre&gt;&lt;code&gt;enum Password {&#10;&#10;    case number(Int, Int, Int, Int) // 32&#10;&#10;    case other&#10;&#10;}&#10;&#10;var pwd = Password.number(5, 6, 4, 7) // 33&#10;pwd = .other // 0&#10;&#10;MemoryLayout&amp;lt;Password&amp;gt;.size // 33&#10;MemoryLayout&amp;lt;Password&amp;gt;.stride // 40&#10;MemoryLayout&amp;lt;Password&amp;gt;.alignment // 8&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>iOS架构设计!iOS开发包二进制化【.a静态库、.framework(静态库、动态库)、.dyld动态库、XCFameworks等】 - 掘金</title><link>https://apolla.cc/posts/tips/ios%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1ios%E5%BC%80%E5%8F%91%E5%8C%85%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96.a%E9%9D%99%E6%80%81%E5%BA%93.framework%E9%9D%99%E6%80%81%E5%BA%93%E5%8A%A8%E6%80%81%E5%BA%93.dyld%E5%8A%A8%E6%80%81%E5%BA%93xcfameworks%E7%AD%89-%E6%8E%98%E9%87%91/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/ios%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1ios%E5%BC%80%E5%8F%91%E5%8C%85%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96.a%E9%9D%99%E6%80%81%E5%BA%93.framework%E9%9D%99%E6%80%81%E5%BA%93%E5%8A%A8%E6%80%81%E5%BA%93.dyld%E5%8A%A8%E6%80%81%E5%BA%93xcfameworks%E7%AD%89-%E6%8E%98%E9%87%91/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;h2 class="heading-element" id="前言"&gt;&lt;span&gt;前言&lt;/span&gt;&#10; &lt;a href="#%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;我们之前通过一篇文章在讨论“&lt;code&gt;移动客户端架构设计&lt;/code&gt;的时候，仅是通过&lt;a href="https://juejin.cn/post/7118599362036367391" target="_blank" rel="external nofollow noopener noreferrer"&gt;一篇文章&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;进行了综述。&lt;/p&gt;</description></item><item><title>可选项</title><link>https://apolla.cc/posts/%E5%8F%AF%E9%80%89%E9%A1%B9/</link><pubDate>Thu, 20 Jun 2024 20:52:48 +0800</pubDate><guid>https://apolla.cc/posts/%E5%8F%AF%E9%80%89%E9%A1%B9/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;ul&gt;&#10;&lt;li&gt;可选项，一般也叫可选类型，它允许将值设置为nil&lt;/li&gt;&#10;&lt;li&gt;在类型名称后面加个问号 ? 来定义一个可选项&lt;/li&gt;&#10;&lt;li&gt;本质上是enum类型 包含一个none和一个关联属性&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;var age: Int?&#10;print(age)&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&#10;&lt;p&gt;例如 下面代码 用于判断数组越界 如果越界就返回空&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;pre&gt;&lt;code&gt;var ages = [10,15,3,9]&#10;&#10; &#10;&#10;func getAges(_ index:Int) -&amp;gt; Int? {&#10;    if index &amp;lt; 0 || index &amp;gt; ages.count {&#10;        return nil&#10;    }&#10;    return ages[index]&#10;}&#10;&#10;print(getAges(1)) //Optional(15)&#10;print(getAges(-1)) //nil&#10;print(getAges(16)) //nil&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="强制解包"&gt;&lt;span&gt;强制解包&lt;/span&gt;&#10; &lt;a href="#%e5%bc%ba%e5%88%b6%e8%a7%a3%e5%8c%85" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;可选项是对其他类型的一层包装，可以将它理解为一个盒子&lt;/li&gt;&#10;&lt;li&gt;如果为nil，那么它是个空盒子&lt;/li&gt;&#10;&lt;li&gt;如果不为nil，那么盒子里装的是：被包装类型的数据&lt;/li&gt;&#10;&lt;li&gt;如果要从可选项中取出被包装的数据（将盒子里装的东西取出来），需要使用感叹号 ! 进行强制解包&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;如果对值为nil的可选项（空盒子）进行强制解包，将会产生运行时错误（Fatal error: Unexpectedly found nil while unwrapping an Optional value）&lt;/strong&gt;&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;var age:Int?&#10;age = 10&#10;var nums = age! &amp;#43; 20&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="可选项绑定letvar-保护"&gt;&lt;span&gt;可选项绑定（let、var 保护）&lt;/span&gt;&#10; &lt;a href="#%e5%8f%af%e9%80%89%e9%a1%b9%e7%bb%91%e5%ae%9aletvar-%e4%bf%9d%e6%8a%a4" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;可以使用可选项绑定来判断可选项是否包含值&lt;/li&gt;&#10;&lt;li&gt;如果包含就自动解包，把值赋给一个临时的常量(let)或者变量(var)，并返回true，否则返回false&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;if let number = Int(&amp;#34;123&amp;#34;){&#10;&#10;    print(&amp;#34;字符串转换整数成功:\(number)&amp;#34;)&#10;&#10;    // number是强制解包之后的Int值&#10;&#10;    // number作用域仅限于这个大括号&#10;&#10;} else {&#10;&#10;    print(&amp;#34;字符串转换整数失败&amp;#34;)&#10;&#10;}&#10;&#10;//字符串转换整数成功:123&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="可选项绑定在while中的用法"&gt;&lt;span&gt;可选项绑定在while中的用法&lt;/span&gt;&#10; &lt;a href="#%e5%8f%af%e9%80%89%e9%a1%b9%e7%bb%91%e5%ae%9a%e5%9c%a8while%e4%b8%ad%e7%9a%84%e7%94%a8%e6%b3%95" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;//遍历数组，将遇到的正数都加起来，如果遇到负数或者非数字，停止遍历&#10;&#10;var strs = [&amp;#34;10&amp;#34;,&amp;#34;20&amp;#34;,&amp;#34;abc&amp;#34;,&amp;#34;-20&amp;#34;,&amp;#34;30&amp;#34;]&#10;&#10;var index = 0&#10;&#10;var sum = 0&#10;&#10;while let num = Int(strs[index]),num &amp;gt; 0 {&#10;&#10;    sum &amp;#43;= num&#10;&#10;    index &amp;#43;= 1&#10;&#10;}&#10;&#10;print(sum)&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="隐式解包尽量少使用"&gt;&lt;span&gt;隐式解包(尽量少使用)&lt;/span&gt;&#10; &lt;a href="#%e9%9a%90%e5%bc%8f%e8%a7%a3%e5%8c%85%e5%b0%bd%e9%87%8f%e5%b0%91%e4%bd%bf%e7%94%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;在某些情况下，可选项一旦被设定值之后，就会一直拥有值&lt;/li&gt;&#10;&lt;li&gt;在这种情况下，可以去掉检查，也不必每次访问的时候都进行解包，因为它能确定每次访问的时候都有值&lt;/li&gt;&#10;&lt;li&gt;可以在类型后面加个感叹号!定义一个隐式解包的可选项&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;let num1: Int! = 10&#10;let num2: Int = num1&#10;if num1 != nil {&#10;    print(num1 &amp;#43; 6)// 16&#10;}&#10;&#10;if let num3 = num1 {&#10;    print(num3)&#10;}&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>空合并运算符??</title><link>https://apolla.cc/posts/%E7%A9%BA%E5%90%88%E5%B9%B6%E8%BF%90%E7%AE%97%E7%AC%A6/</link><pubDate>Tue, 09 Apr 2024 16:16:57 +0800</pubDate><guid>https://apolla.cc/posts/%E7%A9%BA%E5%90%88%E5%B9%B6%E8%BF%90%E7%AE%97%E7%AC%A6/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="描述"&gt;&lt;span&gt;描述&lt;/span&gt;&#10; &lt;a href="#%e6%8f%8f%e8%bf%b0" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;a?? b&lt;/li&gt;&#10;&lt;li&gt;a 是可选项&lt;/li&gt;&#10;&lt;li&gt;b 是可选项 或者 不是可选项&lt;/li&gt;&#10;&lt;li&gt;b 跟 a 的存储类型必须相同&lt;/li&gt;&#10;&lt;li&gt;如果 a 不为nil,就返回 a&lt;/li&gt;&#10;&lt;li&gt;如果a 为nil,就返回 b&lt;/li&gt;&#10;&lt;li&gt;如果 b 不是可选项，返回 a 时会自动解包&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;举例说明&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>结构体和类</title><link>https://apolla.cc/posts/%E7%BB%93%E6%9E%84%E4%BD%93%E5%92%8C%E7%B1%BB/</link><pubDate>Wed, 10 Apr 2024 17:17:06 +0800</pubDate><guid>https://apolla.cc/posts/%E7%BB%93%E6%9E%84%E4%BD%93%E5%92%8C%E7%B1%BB/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;ul&gt;&#10;&lt;li&gt;在 Swift 标准库中，绝大多数的公开类型都是结构体，而枚举和类只占很小一部分&lt;/li&gt;&#10;&lt;li&gt;比如Bool、 Int、 Double、 String、 Array、 Dictionary等常见类型都是结构体&lt;/li&gt;&#10;&lt;li&gt;所有的结构体都有一个编译器自动生成的初始化器（ initializer，初始化方法、构造器、构造方法）&lt;/li&gt;&#10;&lt;li&gt;在第⑥行调用的，可以传入所有成员值，用以初始化所有成员（存储属性， Stored Property）&lt;/li&gt;&#10;&lt;li&gt;编译器会根据情况，可能会为结构体生成多个初始化器，宗旨是：保证所有成员都有初始值&lt;/li&gt;&#10;&lt;li&gt;一旦在定义结构体时自定义了初始化器，编译器就不会再帮它自动生成其他初始化器&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;struct Date {&#10;    var year:Int&#10;    var month:Int&#10;    var day:Int&#10;}&#10;&#10;var deate = Date(year: 2024, month: 3, day: 24)&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="类"&gt;&lt;span&gt;类&lt;/span&gt;&#10; &lt;a href="#%e7%b1%bb" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;类的定义和结构体类似，但编译器并没有为类自动生成可以传入成员值的初始化器&lt;/li&gt;&#10;&lt;li&gt;如果类的所有成员都在定义的时候指定了初始值，编译器会为类生成无参的初始化器&lt;/li&gt;&#10;&lt;li&gt;成员的初始化是在这个初始化器中完成的&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="结构体与类的本质区别"&gt;&lt;span&gt;结构体与类的本质区别&lt;/span&gt;&#10; &lt;a href="#%e7%bb%93%e6%9e%84%e4%bd%93%e4%b8%8e%e7%b1%bb%e7%9a%84%e6%9c%ac%e8%b4%a8%e5%8c%ba%e5%88%ab" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;结构体是值类型（枚举也是值类型），类是引用类型（指针类型）&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;!&lt;/p&gt;</description></item><item><title>闭包</title><link>https://apolla.cc/posts/%E9%97%AD%E5%8C%85/</link><pubDate>Thu, 11 Apr 2024 17:12:41 +0800</pubDate><guid>https://apolla.cc/posts/%E9%97%AD%E5%8C%85/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;blockquote&gt;&#10;&lt;p&gt;在Swift中，可以通过func定义一个函数，也可以通过闭包表达式定义一个函数&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h2 class="heading-element" id="闭包表达式"&gt;&lt;span&gt;闭包表达式&lt;/span&gt;&#10; &lt;a href="#%e9%97%ad%e5%8c%85%e8%a1%a8%e8%be%be%e5%bc%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;pre&gt;&lt;code&gt;{&#10;(参数列表) -&amp;gt; 返回值类型 in&#10;函数体代码&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;举例：&lt;/p&gt;</description></item><item><title>属性</title><link>https://apolla.cc/posts/%E5%B1%9E%E6%80%A7/</link><pubDate>Fri, 12 Apr 2024 10:29:42 +0800</pubDate><guid>https://apolla.cc/posts/%E5%B1%9E%E6%80%A7/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;p&gt;Swift中跟实例相关的属性可以分为2大类&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;存储属性（ Stored Property）&#10;&lt;ul&gt;&#10;&lt;li&gt;类似于成员变量这个概念&lt;/li&gt;&#10;&lt;li&gt;存储在实例的内存中&lt;/li&gt;&#10;&lt;li&gt;结构体、类可以定义存储属性&lt;/li&gt;&#10;&lt;li&gt;枚举不可以定义存储属性&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;计算属性（ Computed Property）&#10;&lt;ul&gt;&#10;&lt;li&gt;本质就是方法（函数）&lt;/li&gt;&#10;&lt;li&gt;不占用实例的内存&lt;/li&gt;&#10;&lt;li&gt;枚举、结构体、类都可以定义计算属性&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="存储属性"&gt;&lt;span&gt;存储属性&lt;/span&gt;&#10; &lt;a href="#%e5%ad%98%e5%82%a8%e5%b1%9e%e6%80%a7" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;关于存储属性， Swift有个明确的规定&lt;/p&gt;</description></item><item><title>方法</title><link>https://apolla.cc/posts/%E6%96%B9%E6%B3%95/</link><pubDate>Fri, 12 Apr 2024 10:45:16 +0800</pubDate><guid>https://apolla.cc/posts/%E6%96%B9%E6%B3%95/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;ul&gt;&#10;&lt;li&gt;枚举、结构体、类都可以定义实例方法、类型方法&#10;&lt;ul&gt;&#10;&lt;li&gt;实例方法（ Instance Method）： 通过实例对象调用&lt;/li&gt;&#10;&lt;li&gt;类型方法（ Type Method）： 通过类型调用，用static或者class关键字定义&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="mutating"&gt;&lt;span&gt;mutating&lt;/span&gt;&#10; &lt;a href="#mutating" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;结构体和枚举是值类型，默认情况下，值类型的属性不能被自身的实例方法修改&lt;/li&gt;&#10;&lt;li&gt;在func关键字前加mutating可以允许这种修改行为&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="discardableresult"&gt;&lt;span&gt;@discardableResult&lt;/span&gt;&#10; &lt;a href="#discardableresult" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;blockquote&gt;&#10;&lt;p&gt;在func前面加个&lt;code&gt;@discardableResult&lt;/code&gt; ， 可以消除：函数调用后返回值未被使用的警告⚠&#10;!&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>下标</title><link>https://apolla.cc/posts/%E4%B8%8B%E6%A0%87/</link><pubDate>Fri, 12 Apr 2024 10:51:32 +0800</pubDate><guid>https://apolla.cc/posts/%E4%B8%8B%E6%A0%87/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;blockquote&gt;&#10;&lt;p&gt;注： 暂未发现应用场景&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h2 class="heading-element" id="不同的下标概念"&gt;&lt;span&gt;不同的下标概念&lt;/span&gt;&#10; &lt;a href="#%e4%b8%8d%e5%90%8c%e7%9a%84%e4%b8%8b%e6%a0%87%e6%a6%82%e5%bf%b5" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;!&lt;/p&gt;&#10;&lt;h2 class="heading-element" id="下标的细节"&gt;&lt;span&gt;下标的细节&lt;/span&gt;&#10; &lt;a href="#%e4%b8%8b%e6%a0%87%e7%9a%84%e7%bb%86%e8%8a%82" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;!&#10;!&lt;/p&gt;</description></item><item><title>继承</title><link>https://apolla.cc/posts/%E7%BB%A7%E6%89%BF/</link><pubDate>Fri, 12 Apr 2024 11:16:39 +0800</pubDate><guid>https://apolla.cc/posts/%E7%BB%A7%E6%89%BF/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;ul&gt;&#10;&lt;li&gt;值类型（枚举、结构体）不支持继承，只有类支持继承&lt;/li&gt;&#10;&lt;li&gt;没有父类的类，称为：基类&#10;&lt;ul&gt;&#10;&lt;li&gt;Swift并没有像OC、 Java那样的规定：任何类最终都要继承自某个基类&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;子类可以重写父类的下标、 方法、 属性，重写必须加上override关键字&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="重写类型方法下标"&gt;&lt;span&gt;重写类型方法、下标&lt;/span&gt;&#10; &lt;a href="#%e9%87%8d%e5%86%99%e7%b1%bb%e5%9e%8b%e6%96%b9%e6%b3%95%e4%b8%8b%e6%a0%87" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;被class修饰的类型方法、下标， 允许被子类重写&lt;/li&gt;&#10;&lt;li&gt;被static修饰的类型方法、下标， 不允许被子类重写&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="重写属性"&gt;&lt;span&gt;重写属性&lt;/span&gt;&#10; &lt;a href="#%e9%87%8d%e5%86%99%e5%b1%9e%e6%80%a7" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;子类可以将父类的属性（存储、计算）重写为计算属性&lt;/li&gt;&#10;&lt;li&gt;子类不可以将父类属性重写为存储属性&lt;/li&gt;&#10;&lt;li&gt;只能重写var属性，不能重写let属性&lt;/li&gt;&#10;&lt;li&gt;重写时，属性名、类型要一致&lt;/li&gt;&#10;&lt;li&gt;子类重写后的属性权限 不能小于 父类属性的权限&#10;&lt;ul&gt;&#10;&lt;li&gt;如果父类属性是只读的，那么子类重写后的属性可以是只读的、也可以是可读写的&lt;/li&gt;&#10;&lt;li&gt;如果父类属性是可读写的，那么子类重写后的属性也必须是可读写的&#10;!&#10;!&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="重写类型属性"&gt;&lt;span&gt;重写类型属性&lt;/span&gt;&#10; &lt;a href="#%e9%87%8d%e5%86%99%e7%b1%bb%e5%9e%8b%e5%b1%9e%e6%80%a7" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;被class修饰的计算类型属性， 可以被子类重写&lt;/li&gt;&#10;&lt;li&gt;被static修饰的类型属性（存储、计算） ， 不可以被子类重写&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="属性观察器"&gt;&lt;span&gt;属性观察器&lt;/span&gt;&#10; &lt;a href="#%e5%b1%9e%e6%80%a7%e8%a7%82%e5%af%9f%e5%99%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;可以在子类中为父类属性（除了只读计算属性、 let属性）增加属性观察器&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="final"&gt;&lt;span&gt;final&lt;/span&gt;&#10; &lt;a href="#final" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;被final修饰的方法、下标、属性，禁止被重写&lt;/li&gt;&#10;&lt;li&gt;被final修饰的类，禁止被继承&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>协议（ Protocol）</title><link>https://apolla.cc/posts/%E5%8D%8F%E8%AE%AE-protocol/</link><pubDate>Mon, 15 Apr 2024 15:11:37 +0800</pubDate><guid>https://apolla.cc/posts/%E5%8D%8F%E8%AE%AE-protocol/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;hr&gt;&#10;&lt;p&gt;&lt;em&gt;协议&lt;/em&gt; 定义了一个蓝图，规定了用来实现某一特定任务或者功能的方法、属性，以及其他需要的东西。类、结构体或枚举都可以遵循协议，并为协议定义的这些要求提供具体实现。某个类型能够满足某个协议的要求，就可以说该类型_遵循_这个协议。&lt;/p&gt;&#10;&lt;p&gt;除了遵循协议的类型必须实现的要求外，还可以对协议进行扩展，通过扩展来实现一部分要求或者实现一些附加功能，这样遵循协议的类型就能够使用这些功能。&lt;/p&gt;</description></item><item><title>杂碎知识</title><link>https://apolla.cc/posts/%E6%9D%82%E7%A2%8E%E7%9F%A5%E8%AF%86/</link><pubDate>Fri, 12 Apr 2024 14:43:57 +0800</pubDate><guid>https://apolla.cc/posts/%E6%9D%82%E7%A2%8E%E7%9F%A5%E8%AF%86/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="anyanyobject"&gt;&lt;span&gt;Any、AnyObject&lt;/span&gt;&#10; &lt;a href="#anyanyobject" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;Swift提供了2种特殊的类型： Any、 AnyObject&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Any：可以代表任意类型（枚举、结构体、类，也包括函数类型）&lt;/li&gt;&#10;&lt;li&gt;AnyObject：可以代表任意类类型（在协议后面写上: AnyObject代表只有类能遵守这个协议）&#10;&lt;ul&gt;&#10;&lt;li&gt;在协议后面写上: class也代表只有类能遵守这个协议&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 class="heading-element" id="is-as-as-as"&gt;&lt;span&gt;is、 as?、 as!、 as&lt;/span&gt;&#10; &lt;a href="#is-as-as-as" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;is用来判断是否为某种类型&lt;/li&gt;&#10;&lt;li&gt;as用来做强制类型转换&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;as&lt;/p&gt;&#10;&lt;p&gt;1）从派生类转换为基类，向上转型（upcasts）&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;</description></item><item><title>Error</title><link>https://apolla.cc/posts/error/</link><pubDate>Mon, 15 Apr 2024 09:22:49 +0800</pubDate><guid>https://apolla.cc/posts/error/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h2 class="heading-element" id="自定义错误"&gt;&lt;span&gt;自定义错误&lt;/span&gt;&#10; &lt;a href="#%e8%87%aa%e5%ae%9a%e4%b9%89%e9%94%99%e8%af%af" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;Swift中可以通过Error协议自定义运行时的错误信息&lt;/li&gt;&#10;&lt;li&gt;函数内部通过throw抛出自定义Error，可能会抛出Error的函数必须加上throws声明&lt;/li&gt;&#10;&lt;li&gt;需要使用try调用可能会抛出Error的函数&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre&gt;&lt;code&gt;enum SomeError : Error {&#10;    case illegalArg(String)&#10;    case outOfBounds(Int, Int)&#10;    case outOfMemory&#10;&#10;}&#10;&#10;func divide(_ num1: Int, _ num2: Int) throws -&amp;gt; Int {&#10;&#10;    if num2 == 0 {&#10;        throw SomeError.illegalArg(&amp;#34;0不能作为除数&amp;#34;)&#10;    }&#10;    return num1 / num2&#10;}&#10;&#10; var value = try divide(20,10)&lt;/code&gt;&lt;/pre&gt;&lt;h2 class="heading-element" id="do-catch-捕捉异常"&gt;&lt;span&gt;do-catch 捕捉异常&lt;/span&gt;&#10; &lt;a href="#do-catch-%e6%8d%95%e6%8d%89%e5%bc%82%e5%b8%b8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;blockquote&gt;&#10;&lt;p&gt;抛出Error后， try下一句直到作用域结束的代码都将停止运行&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>泛型</title><link>https://apolla.cc/posts/%E6%B3%9B%E5%9E%8B/</link><pubDate>Mon, 15 Apr 2024 14:13:34 +0800</pubDate><guid>https://apolla.cc/posts/%E6%B3%9B%E5%9E%8B/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;p&gt;泛型可以将类型参数化，提高代码复用率，减少代码量&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;func swapValues&amp;lt;T&amp;gt;(_ a: inout T, _ b: inout T) {&#10;    (a, b) = (b, a)&#10;}&#10;&#10;enum Score&amp;lt;T&amp;gt; {&#10;    case point(T)&#10;    case grade(String)&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="a-泛型函数"&gt;&lt;span&gt;A. 泛型函数&lt;/span&gt;&#10; &lt;a href="#a-%e6%b3%9b%e5%9e%8b%e5%87%bd%e6%95%b0" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;blockquote&gt;&#10;&lt;p&gt;泛型函数指的是：函数的&lt;code&gt;参数&lt;/code&gt;或&lt;code&gt;返回值&lt;/code&gt;类型使用&lt;code&gt;泛型&lt;/code&gt;，而&lt;code&gt;不是具体的类型&lt;/code&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>运算符重载</title><link>https://apolla.cc/posts/%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD/</link><pubDate>Mon, 15 Apr 2024 14:55:01 +0800</pubDate><guid>https://apolla.cc/posts/%E8%BF%90%E7%AE%97%E7%AC%A6%E9%87%8D%E8%BD%BD/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;p&gt;在C++中, 运算符是可以重载的, Swift也是支持的&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;注：&lt;code&gt;=&lt;/code&gt;和三目运算符&lt;code&gt;a ? b : c&lt;/code&gt;不可重载&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;重载双目运算符&lt;/strong&gt;&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;class Vector {&#10; var x: Double = 0.0&#10; var y: Double = 0.0&#10; var z: Double = 0.0&#10; &#10; init(x: Double, y: Double, z: Double) {&#10; self.x = x&#10; self.y = y&#10; self.z = z&#10; }&#10; &#10; convenience init() {&#10; self.init(x: 0, y: 0, z: 0) &#10; }&#10; &#10; &#10; &#10; static func &amp;#43;(v1: Vector, v2: Vector) -&amp;gt; Vector {&#10; let vector: Vector = Vector()&#10; vector.x = v1.x &amp;#43; v2.x&#10; vector.y = v1.y &amp;#43; v2.y&#10; vector.z = v1.z &amp;#43; v2.z&#10; return vector&#10; }&#10;} &lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;单目运算符&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>扩展</title><link>https://apolla.cc/posts/%E6%89%A9%E5%B1%95/</link><pubDate>Mon, 15 Apr 2024 15:07:54 +0800</pubDate><guid>https://apolla.cc/posts/%E6%89%A9%E5%B1%95/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;p&gt;&lt;em&gt;扩展_可以给一个现有的类，结构体，枚举，还有协议添加新的功能。它还拥有不需要访问被扩展类型源代码就能完成扩展的能力（即_逆向建模&lt;/em&gt;）。扩展和 Objective-C 的分类很相似。（与 Objective-C 分类不同的是，Swift 扩展是没有名字的。）&lt;/p&gt;&#10;&lt;p&gt;Swift 中的扩展可以：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;添加计算型实例属性和计算型类属性&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;定义实例方法和类方法&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;提供新的构造器&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;定义下标&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;定义和使用新的嵌套类型&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;使已经存在的类型遵循（conform）一个协议&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>函数式编程、协议编程、响应式编程</title><link>https://apolla.cc/posts/%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B%E5%8D%8F%E8%AE%AE%E7%BC%96%E7%A8%8B%E5%93%8D%E5%BA%94%E5%BC%8F%E7%BC%96%E7%A8%8B/</link><pubDate>Mon, 15 Apr 2024 16:31:53 +0800</pubDate><guid>https://apolla.cc/posts/%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B%E5%8D%8F%E8%AE%AE%E7%BC%96%E7%A8%8B%E5%93%8D%E5%BA%94%E5%BC%8F%E7%BC%96%E7%A8%8B/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h3 class="heading-element" id="1函数式编程"&gt;&lt;span&gt;1、函数式编程&lt;/span&gt;&#10; &lt;a href="#1%e5%87%bd%e6%95%b0%e5%bc%8f%e7%bc%96%e7%a8%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;h5 class="heading-element" id="1array-常见方法"&gt;&lt;span&gt;1、Array 常见方法&lt;/span&gt;&#10; &lt;a href="#1array-%e5%b8%b8%e8%a7%81%e6%96%b9%e6%b3%95" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h5&gt;&lt;pre&gt;&lt;code&gt;var arr = [1, 2, 3, 4]&#10;&#10;var arr2 = arr.map { $0 * 2 }&#10;&#10;var arr3 = arr.filter { $0 % 2 == 0 }&#10;&#10;var arr4 = arr.reduce(0) { $0 &amp;#43; $1 }&#10;&#10;var arr5 = arr.reduce(0, &amp;#43;) &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;func double(_ i: Int) -&amp;gt; Int { i * 2 }&#10;var arr = [1, 2, 3, 4]&#10;&#10;print(arr.map(double)) &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var arr = [1, 2, 3]&#10;&#10;var arr2 = arr.map { Array.init(repeating: $0, count: $0) }&#10;&#10;var arr3 = arr.flatMap { Array.init(repeating: $0, count: $0) } &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var arr = [&amp;#34;123&amp;#34;, &amp;#34;test&amp;#34;, &amp;#34;jack&amp;#34;, &amp;#34;-30&amp;#34;]&#10;&#10;var arr2 = arr.map { Int($0) }&#10;&#10;var arr3 = arr.compactMap { Int($0) } &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;// 使用reduce实现map、filter的功能&#10;var arr = [1, 2, 3, 4]&#10;// [2, 4, 6, 8]&#10;print(arr.map { $0 * 2 })&#10;print(arr.reduce([]) { $0 &amp;#43; [$1 * 2] })&#10;// [2, 4]&#10;print(arr.filter { $0 % 2 == 0 })&#10;print(arr.reduce([]) { $1 % 2 == 0 ? $0 &amp;#43; [$1] : $0 }) &lt;/code&gt;&lt;/pre&gt;&lt;h5 class="heading-element" id="2lazy-的优化"&gt;&lt;span&gt;2、lazy 的优化&lt;/span&gt;&#10; &lt;a href="#2lazy-%e7%9a%84%e4%bc%98%e5%8c%96" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h5&gt;&lt;pre&gt;&lt;code&gt;let arr = [1, 2, 3]&#10;let result = arr.lazy.map { (i: Int) -&amp;gt; Int in&#10; print(&amp;#34;mapping \(i)&amp;#34;)&#10; return i * 2&#10;}&#10;print(&amp;#34;begin-----&amp;#34;)&#10;print(&amp;#34;mapped&amp;#34;, result[0])&#10;print(&amp;#34;mapped&amp;#34;, result[1])&#10;print(&amp;#34;mapped&amp;#34;, result[2])&#10;print(&amp;#34;end----&amp;#34;)&#10;&#10;begin-----&#10;mapping 1&#10;mapped 2&#10;mapping 2&#10;mapped 4&#10;mapping 3&#10;mapped 6&#10;end---- &lt;/code&gt;&lt;/pre&gt;&lt;h5 class="heading-element" id="3optional-的-map-和-flatmap"&gt;&lt;span&gt;3、Optional 的 map 和 flatMap&lt;/span&gt;&#10; &lt;a href="#3optional-%e7%9a%84-map-%e5%92%8c-flatmap" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h5&gt;&lt;pre&gt;&lt;code&gt;var num1: Int? = 10&#10;&#10;var num2 = num1.map { $0 * 2 }&#10;var num3: Int? = nil&#10;&#10;var num4 = num3.map { $0 * 2 } &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var num1: Int? = 10&#10;&#10;var num2 = num1.map { Optional.some($0 * 2) }&#10;&#10;var num3 = num1.flatMap { Optional.some($0 * 2) } &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var num1: Int? = 10&#10;var num2 = (num1 != nil) ? (num1! &amp;#43; 10) : nil&#10;var num3 = num1.map { $0 &amp;#43; 10 } &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var fmt = DateFormatter()&#10;fmt.dateFormat = &amp;#34;yyyy-MM-dd&amp;#34;&#10;var str: String? = &amp;#34;2011-09-10&amp;#34;&#10;&#10;var date1 = str != nil ? fmt.date(from: str!) : nil&#10;&#10;var date2 = str.flatMap(fmt.date) &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;var score: Int? = 98&#10;&#10;var str1 = score != nil ? &amp;#34;socre is \(score!)&amp;#34; : &amp;#34;No score&amp;#34;&#10;&#10;var str2 = score.map { &amp;#34;score is \($0)&amp;#34; } ?? &amp;#34;No score&amp;#34; &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;struct Person {&#10; var name: String&#10; var age: Int&#10;}&#10;var items = [&#10; Person(name: &amp;#34;jack&amp;#34;, age: 20),&#10; Person(name: &amp;#34;rose&amp;#34;, age: 21),&#10; Person(name: &amp;#34;kate&amp;#34;, age: 22)&#10;]&#10;&#10;func getPerson1(_ name: String) -&amp;gt; Person? {&#10; let index = items.firstIndex { $0.name == name }&#10; return index != nil ? items[index!] : nil&#10;}&#10;&#10;func getPerson2(_ name: String) -&amp;gt; Person? {&#10; return items.firstIndex { $0.name == name }.map { items[$0] }&#10;} &lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;struct Person {&#10; var name: String&#10; var age: Int&#10; init?(_ json: [String : Any]) {&#10; guard let name = json[&amp;#34;name&amp;#34;] as? String, let age = json[&amp;#34;age&amp;#34;] as? Int else {&#10; return nil&#10; }&#10; self.name = name&#10; self.age = age&#10; }&#10;}&#10;var json: Dictionary? = [&amp;#34;name&amp;#34; : &amp;#34;Jack&amp;#34;, &amp;#34;age&amp;#34; : 10]&#10;&#10;var p1 = json != nil ? Person(json!) : nil&#10;&#10;var p2 = json.flatMap(Person.init) &lt;/code&gt;&lt;/pre&gt;&lt;h5 class="heading-element" id="4函数式编程"&gt;&lt;span&gt;4、函数式编程&lt;/span&gt;&#10; &lt;a href="#4%e5%87%bd%e6%95%b0%e5%bc%8f%e7%bc%96%e7%a8%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h5&gt;&lt;p&gt;函数式编程（Funtional Programming，简称FP）是一种编程范式，也就是如何编写程序的方法论。&lt;br&gt;&#10;主要思想：&lt;code&gt;把计算过程尽量分解成一系列可复用函数的调用&lt;/code&gt;。&lt;br&gt;&#10;主要特征：函数是&lt;code&gt;第一等公民&lt;/code&gt;。函数与其他数据类型一样的地位，可以赋值给其他变量，也可以作为函数参数、函数返回值。&lt;/p&gt;</description></item><item><title>访问控制、内存管理、字面量、模式匹配</title><link>https://apolla.cc/posts/%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86%E5%AD%97%E9%9D%A2%E9%87%8F%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D/</link><pubDate>Mon, 15 Apr 2024 16:37:01 +0800</pubDate><guid>https://apolla.cc/posts/%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86%E5%AD%97%E9%9D%A2%E9%87%8F%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D/</guid><category domain="https://apolla.cc/categories/swift/">Swift</category><description>&lt;h3 class="heading-element" id="1访问控制"&gt;&lt;span&gt;1、访问控制&lt;/span&gt;&#10; &lt;a href="#1%e8%ae%bf%e9%97%ae%e6%8e%a7%e5%88%b6" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;Swift 提供了5个不同的访问级别：open &amp;gt; public &amp;gt; internal &amp;gt; fileprivate &amp;gt; private&lt;br&gt;&#10;open：允许在定义实体的模块、其他模块中访问，允许其他模块进行继承、重写（open只能用在类、类成员上）。&lt;br&gt;&#10;public：允许在定义实体的模块、其他模块中访问，不允许其他模块进行继承、重写。&lt;br&gt;&#10;internal：只允许在定义实体的模块中访问，不允许在其他模块中访问。绝大部分实体默认都是该级别。&lt;br&gt;&#10;fileprivate：只允许在定义实体的源文件中访问。&lt;br&gt;&#10;private：只允许在定义实体的封闭声明中访问。&lt;/p&gt;</description></item><item><title>10： IOS安装FFmpeg问题总结</title><link>https://apolla.cc/posts/live/10-ios%E5%AE%89%E8%A3%85ffmpeg%E9%97%AE%E9%A2%98%E6%80%BB%E7%BB%93/</link><pubDate>Sun, 10 Mar 2024 09:54:01 +0800</pubDate><guid>https://apolla.cc/posts/live/10-ios%E5%AE%89%E8%A3%85ffmpeg%E9%97%AE%E9%A2%98%E6%80%BB%E7%BB%93/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;&lt;strong&gt;说一下我自己的情况。还有（ios下的ffmpegh可以下载，代码由我改，基本没啥问题）&lt;/strong&gt;&#10;&lt;strong&gt;下载地址：&lt;/strong&gt;&lt;a href="http://download.csdn.net/detail/nil88/9351775" target="_blank" rel="external nofollow noopener noreferrer"&gt;ffmpegh&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;strong&gt;(怎么用可以看文章）&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;1、我是自己下载ffmpeg2.8.3版本，然后加最新的faac,x264来编译的arm64，armv7,armv7s（iphone所有的arm架构了，我是真机测试，所有不用i386了）。&#10;编译的脚本从这里弄的：&#10;&lt;a href="http://blog.csdn.net/leixiaohua1020/article/details/47071547" target="_blank" rel="external nofollow noopener noreferrer"&gt;http://blog.csdn.net/leixiaohua1020/article/details/47071547&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>1：技术分析与实现</title><link>https://apolla.cc/posts/live/1%E6%8A%80%E6%9C%AF%E5%88%86%E6%9E%90%E4%B8%8E%E5%AE%9E%E7%8E%B0/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/1%E6%8A%80%E6%9C%AF%E5%88%86%E6%9E%90%E4%B8%8E%E5%AE%9E%E7%8E%B0/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;&lt;strong&gt;HTTP Live Streaming直播(iOS直播)技术分析与实现&lt;/strong&gt;&#10;花了一些时间研究了&lt;strong&gt;HTTP Live Streaming&lt;/strong&gt;（&lt;strong&gt;HLS&lt;/strong&gt;）技术，并实现了一个HLS编码器&lt;strong&gt;HLSLiveEncoder&lt;/strong&gt;，当然，C++写的。其功能是采集摄像头与麦克风，实时进行H.264视频编码和AAC音频编码，并按照HLS的协议规范，生成分段的标准TS文件以及m3u8索引文件。通过我的&lt;strong&gt;HLSLiveEncoder&lt;/strong&gt;和第三方Http服务器（例如：Nginx），成功实现了&lt;strong&gt;HTTP Live Streaming&lt;/strong&gt;直播，并在iphone上测试通过。&#10;&lt;strong&gt;HLS技术要点分析&lt;/strong&gt;&#10;&lt;strong&gt;HTTP Live Streaming&lt;/strong&gt;（&lt;strong&gt;HLS&lt;/strong&gt;）是苹果公司(Apple Inc.)实现的基于HTTP的流媒体传输协议，可实现流媒体的直播和点播，主要应用在&lt;strong&gt;iOS&lt;/strong&gt;系统，为&lt;strong&gt;iOS&lt;/strong&gt;设备（如iPhone、iPad）提供音视频直播和点播方案。&lt;strong&gt;HLS&lt;/strong&gt;点播，基本上就是常见的分段HTTP点播，不同在于，它的分段非常小。要实现&lt;strong&gt;HLS&lt;/strong&gt;点播，重点在于对媒体文件分段，目前有不少开源工具可以使用，这里我就不再讨论，只谈HLS直播技术。&#10;相对于常见的流媒体直播协议，例如&lt;a href="http://www.cnblogs.com/haibindev/archive/2011/12/29/2305712.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;RTMP协议&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;、RTSP协议、MMS协议等，HLS直播最大的不同在于，直播客户端获取到的，并不是一个完整的数据流。HLS协议在服务器端将直播数据流存储为连续的、很短时长的媒体文件（&lt;strong&gt;MPEG-TS&lt;/strong&gt;格式），而客户端则不断的下载并播放这些小文件，因为服务器端总是会将最新的直播数据生成新的小文件，这样客户端只要不停的按顺序播放从服务器获取到的文件，就实现了直播。由此可见，基本上可以认为，HLS是以点播的技术方式来实现直播。由于数据通过HTTP协议传输，所以完全不用考虑防火墙或者代理的问题，而且分段文件的时长很短，客户端可以很快的选择和切换码率，以适应不同带宽条件下的播放。不过HLS的这种技术特点，决定了它的延迟一般总是会高于普通的流媒体直播协议。&#10;根据以上的了解要实现&lt;strong&gt;HTTP Live Streaming&lt;/strong&gt;直播，需要研究并实现以下技术关键点&lt;/p&gt;</description></item><item><title>11： iOS下利用FFmpeg命令行进行视频裁剪</title><link>https://apolla.cc/posts/live/11-ios%E4%B8%8B%E5%88%A9%E7%94%A8ffmpeg%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BF%9B%E8%A1%8C%E8%A7%86%E9%A2%91%E8%A3%81%E5%89%AA/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/11-ios%E4%B8%8B%E5%88%A9%E7%94%A8ffmpeg%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BF%9B%E8%A1%8C%E8%A7%86%E9%A2%91%E8%A3%81%E5%89%AA/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;安装&lt;a href="http://linux.softpedia.com/get/Programming/Assembler-Tools/Yasm-621.shtml" target="_blank" rel="external nofollow noopener noreferrer"&gt;yasm&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;• 进入下载后的yasm文件夹，通过编译安装命令yasm:&#10;./configure &amp;amp;&amp;amp; make -j 4 &amp;amp;&amp;amp; sudo make install&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;a href="https://github.com/applexiaohao/gas-preprocessor.git" target="_blank" rel="external nofollow noopener noreferrer"&gt;gas-preprocessor&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;• 打开终端Terminal，进入下载后的gas-preprocessor文件夹:&#10;1.将文件夹内的gas-preprocessor.pl文件拷贝到/usr/local/bin目录下&#10;2.chmod 777 /usr/local/bin/gas-preprocessor.pl&lt;/p&gt;</description></item><item><title>12：基于ijkplayer 视频流 播放</title><link>https://apolla.cc/posts/live/12%E5%9F%BA%E4%BA%8Eijkplayer-%E8%A7%86%E9%A2%91%E6%B5%81-%E6%92%AD%E6%94%BE/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/12%E5%9F%BA%E4%BA%8Eijkplayer-%E8%A7%86%E9%A2%91%E6%B5%81-%E6%92%AD%E6%94%BE/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;&lt;strong&gt;之前开始使用ijk进行了一些简单的播放器实现，不过因为项目需要，所以又重新花了一些时间完善了一个demo&lt;/strong&gt;&#10;主要是对工具栏的逻辑进行了优化，顺便封装了一下，不过第一次做播放器，难免在一些地方有所疏漏，而且时间仓促，一些细节部分暂时还未完善。&#10;主要的一些文件：（参考ijk自带demo）&#10;&lt;img loading="lazy" src='https://apolla.cc/images/2e4035c9f7a7626982e53bafc0e4e915.png' alt="image.png"&gt;&lt;/p&gt;</description></item><item><title>13： ijkplayer 等多个项目开源</title><link>https://apolla.cc/posts/live/13-ijkplayer-%E7%AD%89%E5%A4%9A%E4%B8%AA%E9%A1%B9%E7%9B%AE%E5%BC%80%E6%BA%90/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/13-ijkplayer-%E7%AD%89%E5%A4%9A%E4%B8%AA%E9%A1%B9%E7%9B%AE%E5%BC%80%E6%BA%90/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;SegmentFault 兄弟 + 基友单位弹幕视频网 Bilibili（B 站）近日在 GitHub 网站上建立了开源工作组（BOSTF）（此处 1024 赞），用以分享与维护自己的开源项目，其中包括 DanmakuFlameMaster（燃烧吧！烈焰弹幕使）与 ijkplayer。前者是免费提供 Android 平台下应用弹幕集成的解决方案，而后者则提供 Android 和 iOS 双平台视频播放器的解决方案。&lt;/p&gt;</description></item><item><title>15： IOS使用ijkPlayer</title><link>https://apolla.cc/posts/live/15-ios%E4%BD%BF%E7%94%A8ijkplayer/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/15-ios%E4%BD%BF%E7%94%A8ijkplayer/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;最近要做一个视频直播的项目，刚刚进入视频坑，开始自己琢磨AVPlayer，使用起来发现还挺多限制的，虽然当然知道要先把基础打好，相关基础链接：&lt;/p&gt;&#10;&lt;p&gt;网络播放器相关&#10;&lt;a href="http://blog.csdn.net/Matthew_Fan/article/category/1200896" target="_blank" rel="external nofollow noopener noreferrer"&gt;http://blog.csdn.net/Matthew_Fan/article/category/1200896&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;HLS流媒体开发&#10;&lt;a href="http://blog.csdn.net/sdvch/article/details/14047281" target="_blank" rel="external nofollow noopener noreferrer"&gt;http://blog.csdn.net/sdvch/article/details/14047281&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;HLS 比较全的中文博客&#10;&lt;a href="http://blog.csdn.net/Matthew_Fan/article/category/1200896" target="_blank" rel="external nofollow noopener noreferrer"&gt;http://blog.csdn.net/Matthew_Fan/article/category/1200896&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;苹果 iOS 开发文档 （HLS）&#10;&lt;a href="https://developer.apple.com/streaming/" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://developer.apple.com/streaming/&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>16：ios视频播放器，代码和界面分离</title><link>https://apolla.cc/posts/live/16ios%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E5%99%A8%E4%BB%A3%E7%A0%81%E5%92%8C%E7%95%8C%E9%9D%A2%E5%88%86%E7%A6%BB/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/16ios%E8%A7%86%E9%A2%91%E6%92%AD%E6%94%BE%E5%99%A8%E4%BB%A3%E7%A0%81%E5%92%8C%E7%95%8C%E9%9D%A2%E5%88%86%E7%A6%BB/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;最近业余时间整理的一个ios播放器，界面采用storyboard,以前几乎都是用代码布局，但是用过一个项目storyboard后，就感觉storyboard很靠谱，团队合作版本控制的问题解决其实很简单，每个人一个storyboard就可以了。播放代码使用的是avplayer，最大的优化就是播放界面和播放代码完全分离。&lt;/p&gt;</description></item><item><title>18：直播时代--IOS直播客户端SDK，美艳直播【开源】</title><link>https://apolla.cc/posts/live/18%E7%9B%B4%E6%92%AD%E6%97%B6%E4%BB%A3--ios%E7%9B%B4%E6%92%AD%E5%AE%A2%E6%88%B7%E7%AB%AFsdk%E7%BE%8E%E8%89%B3%E7%9B%B4%E6%92%AD%E5%BC%80%E6%BA%90/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/18%E7%9B%B4%E6%92%AD%E6%97%B6%E4%BB%A3--ios%E7%9B%B4%E6%92%AD%E5%AE%A2%E6%88%B7%E7%AB%AFsdk%E7%BE%8E%E8%89%B3%E7%9B%B4%E6%92%AD%E5%BC%80%E6%BA%90/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;h1 class="heading-element" id="直播时代ios直播客户端sdk美艳直播开源"&gt;&lt;span&gt;&lt;a href="https://www.cnblogs.com/Hakim/p/5242304.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;直播时代&amp;ndash;IOS直播客户端SDK，美艳直播【开源】&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&#10; &lt;a href="#%e7%9b%b4%e6%92%ad%e6%97%b6%e4%bb%a3ios%e7%9b%b4%e6%92%ad%e5%ae%a2%e6%88%b7%e7%ab%afsdk%e7%be%8e%e8%89%b3%e7%9b%b4%e6%92%ad%e5%bc%80%e6%ba%90" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;看到该文章我非常喜欢，为了方便自己查看和参考所以将其复制过来，源文地址：http://www.cnblogs.com/runner42/p/5241407.html&#10;请支持原作者。原作者如看到请原谅复制您的，纯属为了方便查阅。&lt;/p&gt;</description></item><item><title>2：RTMP协议学习总结</title><link>https://apolla.cc/posts/live/2rtmp%E5%8D%8F%E8%AE%AE%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/2rtmp%E5%8D%8F%E8%AE%AE%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;RTMP协议是一个互联网TCP/IP五层体系结构中应用层的协议。RTMP协议中基本的数据单元称为消息（Message）。当RTMP协议在互联网中传输数据的时候，消息会被拆分成更小的单元，称为消息块（Chunk）。&#10;1 消息&#10;消息是RTMP协议中基本的数据单元。不同种类的消息包含不同的Message Type ID，代表不同的功能。RTMP协议中一共规定了十多种消息类型，分别发挥着不同的作用。例如，Message Type ID在1-7的消息用于协议控制，这些消息一般是RTMP协议自身管理要使用的消息，用户一般情况下无需操作其中的数据。Message Type ID为8，9的消息分别用于传输音频和视频数据。Message Type ID为15-20的消息用于发送AMF编码的命令，负责用户与服务器之间的交互，比如播放，暂停等等。消息首部（Message Header）有四部分组成：标志消息类型的Message Type ID，标志消息长度的Payload Length，标识时间戳的Timestamp，标识消息所属媒体流的Stream ID。消息的报文结构如下图所示。&lt;/p&gt;</description></item><item><title>4：readValue、setNotifyValue、writeValue的含义和使用</title><link>https://apolla.cc/posts/bluetooth/4readvaluesetnotifyvaluewritevalue%E7%9A%84%E5%90%AB%E4%B9%89%E5%92%8C%E4%BD%BF%E7%94%A8/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/4readvaluesetnotifyvaluewritevalue%E7%9A%84%E5%90%AB%E4%B9%89%E5%92%8C%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;p&gt;我们使用nRF Connect(一个调试蓝牙的第三方工具)先连接一个设备，可以看到设备相关信息，如下：&lt;/p&gt;&#10;&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/284a273964c0ab86feba0789b80ad98c.png' alt="image.png"&gt;&#10;中标红色的就是特征值，代表相关服务的特性。特征值有三种，分别是readValue(读取)、setNotifyValue(订阅)、writeValue(写入)。 readValue说明是可读的，回调方法为&lt;/p&gt;</description></item><item><title>4：如何做一款inke版的APP</title><link>https://apolla.cc/posts/live/4%E5%A6%82%E4%BD%95%E5%81%9A%E4%B8%80%E6%AC%BEinke%E7%89%88%E7%9A%84app/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/4%E5%A6%82%E4%BD%95%E5%81%9A%E4%B8%80%E6%AC%BEinke%E7%89%88%E7%9A%84app/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;h1 class="heading-element" id="一直播现状简介"&gt;&lt;span&gt;一、直播现状简介&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80%e7%9b%b4%e6%92%ad%e7%8e%b0%e7%8a%b6%e7%ae%80%e4%bb%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;h2 class="heading-element" id="1技术实现层面"&gt;&lt;span&gt;1.技术实现层面&lt;/span&gt;&#10; &lt;a href="#1%e6%8a%80%e6%9c%af%e5%ae%9e%e7%8e%b0%e5%b1%82%e9%9d%a2" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;技术相对都比较成熟，设备也都支持硬编码。iOS还提供现成的Video ToolBox框架，可以对摄像头和流媒体数据结构进行处理，但Video ToolBox框架只兼容8.0以上版本，8.0以下就需要用x264的库软编了。&#10;github 上有现成的开源实现，推流、美颜、水印、弹幕、点赞动画、滤镜、播放都有。技术其实不是很难，而且现在很多云厂商都提供SDK，七牛云、金山云、乐视云、 腾讯云、百度云、斗鱼直播伴侣推流端，功能几乎都是一样的，没啥亮点，不同的是整个直播平台服务差异和接入的简易性。后端现在 RTMP/HTTP-FLV 清一色，App挂个源站直接接入云厂商或CDN就OK。&lt;/p&gt;</description></item><item><title>5：推流发布和播放【RTMP】介绍</title><link>https://apolla.cc/posts/live/5%E6%8E%A8%E6%B5%81%E5%8F%91%E5%B8%83%E5%92%8C%E6%92%AD%E6%94%BErtmp%E4%BB%8B%E7%BB%8D/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/5%E6%8E%A8%E6%B5%81%E5%8F%91%E5%B8%83%E5%92%8C%E6%92%AD%E6%94%BErtmp%E4%BB%8B%E7%BB%8D/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;准备工作（&lt;sub&gt;表示安装目录）：&#10;1、在&lt;/sub&gt;/applications下创建一个live文件夹`&lt;/p&gt;&#10;&lt;p&gt;2、在~/conf下创建一个live文件夹，并把conf目录下的Application.xml复制进去&lt;/p&gt;&#10;&lt;p&gt;3、编辑Application.xml：&#10;（1）设置Streams/StreamType属性（live：仅直播；record：仅记录；live-record：既直播又记录）&#10;&lt;StreamType&gt;live&lt;/StreamType&gt;&#10;注意：记录的视频保存在~/content目录下。&#10;（2）设置HTTPStreamers属性：&#10;&lt;HTTPStreamers&gt;cupertinostreaming,smoothstreaming,sanjosestreaming&lt;/HTTPStreamers&gt;&#10;（3）设置Streams/LiveStreamPacketizers属性：&#10;&lt;LiveStreamPacketizers&gt;cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer&lt;/LiveStreamPacketizers&gt;&#10;（4）设置RTP/Authentication/PlayMethod属性：&#10;&lt;PlayMethod&gt;none&lt;/PlayMethod&gt;&lt;/p&gt;</description></item><item><title>7：最简单的基于FFmpeg的推流器</title><link>https://apolla.cc/posts/live/7%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E5%9F%BA%E4%BA%8Effmpeg%E7%9A%84%E6%8E%A8%E6%B5%81%E5%99%A8/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/7%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E5%9F%BA%E4%BA%8Effmpeg%E7%9A%84%E6%8E%A8%E6%B5%81%E5%99%A8/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;本文记录一个最简单的基于FFmpeg的推流器（simplest ffmpeg streamer）。推流器的作用就是将本地的视频数据推送至流媒体服务器。本文记录的推流器，可以将本地的 MOV / AVI / MKV / MP4 / FLV 等格式的媒体文件，通过流媒体协议（例如RTMP，HTTP，UDP，TCP，RTP等等）以直播流的形式推送出去。由于流媒体协议种类繁多，不一一记录。在这里记录将本地文件以RTMP直播流的形式推送至RTMP流媒体服务器（例如 Flash Media Server，Red5，Wowza等等）的方法。&lt;/p&gt;</description></item><item><title>9：编译ffmpeg和集成第三方实现直播（监控类）</title><link>https://apolla.cc/posts/live/9%E7%BC%96%E8%AF%91ffmpeg%E5%92%8C%E9%9B%86%E6%88%90%E7%AC%AC%E4%B8%89%E6%96%B9%E5%AE%9E%E7%8E%B0%E7%9B%B4%E6%92%AD%E7%9B%91%E6%8E%A7%E7%B1%BB/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/live/9%E7%BC%96%E8%AF%91ffmpeg%E5%92%8C%E9%9B%86%E6%88%90%E7%AC%AC%E4%B8%89%E6%96%B9%E5%AE%9E%E7%8E%B0%E7%9B%B4%E6%92%AD%E7%9B%91%E6%8E%A7%E7%B1%BB/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;最近由于项目需要，接触了一下ffmpeg的编译和使用。&#10;由于之前的版本ffmpeg编译的库比较老，对新设备，5s及5s以后的设备支持不太好，重新编译了ffmpeg静态库。&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;一，下载并在终端中运行脚本编译ffmpeg&lt;/strong&gt;&#10;脚本参考git上的：https://github.com/kewlbear/FFmpeg-iOS-build-script；&#10;终端进入刚刚下载后的脚本文件夹下，运行sh：build－ffmpeg.sh 自动编译，有缺少yasm的按照提示操作，安装yasm&#10;编译的是ffmpeg2.5.3版本，Xcode6下iOS8.1。&#10;按照脚本编译完后的静态库目录如下：&#10;&lt;img loading="lazy" src='https://apolla.cc/images/0efea1bcb6650694d5c8738c09f2eda6.png' alt="image.png"&gt;&lt;/p&gt;</description></item><item><title>Apple Configurator 2 之 Web Clips - 简书</title><link>https://apolla.cc/posts/tips/apple-configurator-2-%E4%B9%8B-web-clips-%E7%AE%80%E4%B9%A6/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/apple-configurator-2-%E4%B9%8B-web-clips-%E7%AE%80%E4%B9%A6/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;h2 class="heading-element" id="一apple-configurator-2"&gt;&lt;span&gt;一、Apple Configurator 2&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80apple-configurator-2" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;h3 class="heading-element" id="11-什么是apple-configurator"&gt;&lt;span&gt;1.1 什么是Apple Configurator&lt;/span&gt;&#10; &lt;a href="#11-%e4%bb%80%e4%b9%88%e6%98%afapple-configurator" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;&lt;a href="https://links.jianshu.com/go?to=https%3A%2F%2Fsupport.apple.com%2Fzh-cn%2Fguide%2Fapple-configurator-2%2Fcadf1802aed%2Fmac" target="_blank" rel="external nofollow noopener noreferrer"&gt;关于 Mac 上的 Apple Configurator 介绍&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>cocoapods 安装</title><link>https://apolla.cc/posts/tips/cocoapods-%E5%AE%89%E8%A3%85/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/cocoapods-%E5%AE%89%E8%A3%85/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;一、安装步骤&#10;安装Homebrew &amp;ndash;&amp;gt; 安装rvm &amp;ndash;&amp;gt; 安装ruby -&amp;gt; 安装cocoapods&lt;/p&gt;&#10;&lt;p&gt;二、检查Homebrew或安装&#10;1、查看安装的版本信息&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;brew --version&#10;&#10;Homebrew 4.0.4-202-gb1ef41c&#10;Homebrew/homebrew-core (git revision fd2e83a24e8; last commit 2023-03-06)&#10;Homebrew/homebrew-cask (git revision c896fe8640; last commit 2023-03-06)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;2、安装Homebrew&#10;方式1：官方提供的安装方法&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;/bin/bash -c &amp;#34;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)&amp;#34;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;方式2：使用国内的源进行安装&lt;/p&gt;</description></item><item><title>iOS CocoaPods组件平滑二进制化解决方案及详细教程</title><link>https://apolla.cc/posts/modularization/ios-cocoapods%E7%BB%84%E4%BB%B6%E5%B9%B3%E6%BB%91%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8F%8A%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/modularization/ios-cocoapods%E7%BB%84%E4%BB%B6%E5%B9%B3%E6%BB%91%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8F%8A%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B/</guid><category domain="https://apolla.cc/categories/%E7%BB%84%E4%BB%B6%E5%8C%96/">组件化</category><description>&lt;p&gt;iOS CocoaPods组件平滑二进制化方案及详细教程&#10;感谢&amp;quot;fly2never_宝贝别哭&amp;quot;。可以使用&lt;a href="https://link.jianshu.com?t=https://github.com/CocoaPods/cocoapods-packager" target="_blank" rel="external nofollow noopener noreferrer"&gt;cocoapods-packager&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;这个插件来方便生成library（静态库，动态库都可以）。&#10;强烈建议生成framework。&lt;/p&gt;</description></item><item><title>iOS CocoaPods组件平滑二进制化解决方案及详细教程二之subspecs篇</title><link>https://apolla.cc/posts/modularization/ios-cocoapods%E7%BB%84%E4%BB%B6%E5%B9%B3%E6%BB%91%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8F%8A%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B%E4%BA%8C%E4%B9%8Bsubspecs%E7%AF%87/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/modularization/ios-cocoapods%E7%BB%84%E4%BB%B6%E5%B9%B3%E6%BB%91%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8F%8A%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B%E4%BA%8C%E4%B9%8Bsubspecs%E7%AF%87/</guid><category domain="https://apolla.cc/categories/%E7%BB%84%E4%BB%B6%E5%8C%96/">组件化</category><description>&lt;h3 class="heading-element" id="这篇文章主要想介绍以下几个部分"&gt;&lt;span&gt;这篇文章主要想介绍以下几个部分：&lt;/span&gt;&#10; &lt;a href="#%e8%bf%99%e7%af%87%e6%96%87%e7%ab%a0%e4%b8%bb%e8%a6%81%e6%83%b3%e4%bb%8b%e7%bb%8d%e4%bb%a5%e4%b8%8b%e5%87%a0%e4%b8%aa%e9%83%a8%e5%88%86" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;ul&gt;&#10;&lt;li&gt;subspecs基本概念&lt;/li&gt;&#10;&lt;li&gt;实际应用的好处&lt;/li&gt;&#10;&lt;li&gt;如何对含有subspecs的CocoaPods库进行二进制化&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 class="heading-element" id="什么是cocoapods的subspecs"&gt;&lt;span&gt;什么是CocoaPods的subspecs&lt;/span&gt;&#10; &lt;a href="#%e4%bb%80%e4%b9%88%e6%98%afcocoapods%e7%9a%84subspecs" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h4&gt;&lt;p&gt;来一个直观点的。顺便为自己的&lt;a href="https://link.jianshu.com?t=https://github.com/baidao/YTXAnimations" target="_blank" rel="external nofollow noopener noreferrer"&gt;YTXAnimations&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;做个广告。&lt;/p&gt;</description></item><item><title>iOS后台保活</title><link>https://apolla.cc/posts/tips/ios%E5%90%8E%E5%8F%B0%E4%BF%9D%E6%B4%BB/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/ios%E5%90%8E%E5%8F%B0%E4%BF%9D%E6%B4%BB/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;项目内嵌了H5导出的包 但是APP进入后台会导致未加载页面无法响应，故此想到后台保活策略 参考网上教程&lt;a href="https://blog.csdn.net/WangQingLei0307/article/details/112002904" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://blog.csdn.net/WangQingLei0307/article/details/112002904&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;&lt;img loading="lazy" src='https://apolla.cc/images/a989415806124ce1898be19020a17517.png' alt="image.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;首先我们就要在Background Modes把音乐对应权限打开。&lt;/p&gt;&#10;&lt;p&gt;这个权限打开后，我们的工作就已经完成了1/3了&lt;/p&gt;&#10;&lt;p&gt;接下来我就就要在app进入后台的时候开始播放无声音的mp3。&lt;/p&gt;</description></item><item><title>iOS开发之UICollectionViewCompositionalLayout</title><link>https://apolla.cc/posts/tips/ios%E5%BC%80%E5%8F%91%E4%B9%8Buicollectionviewcompositionallayout/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/ios%E5%BC%80%E5%8F%91%E4%B9%8Buicollectionviewcompositionallayout/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;blockquote&gt;&#10;&lt;p&gt;横向滚动+竖向滚动的collectionView iOS13.0开始支持&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;日常开发中最常用的控件莫过于 UITableView 和 UICollectionView，随着应用越来越复杂，以前的 UICollectionViewFlowLayout 布局已经满足不了需求，而自定义布局又过于复杂，所以在 iOS 13 中 Apple 为 UICollectionView 推出了组合布局 UICollectionViewCompositionalLayout，这对于 UICollectionView 是一个全新的升级，它将赋予 UICollectionView 更多的可能性。&lt;/p&gt;</description></item><item><title>RGB、YUV</title><link>https://apolla.cc/posts/media/rgbyuv/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/media/rgbyuv/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>&lt;h1 class="heading-element" id="一rgb编码格式"&gt;&lt;span&gt;一、RGB编码格式&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80rgb%e7%bc%96%e7%a0%81%e6%a0%bc%e5%bc%8f" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;a href="https://so.csdn.net/so/search?q=RGB%E5%9B%BE%E5%83%8F&amp;spm=1001.2101.3001.7020" target="_blank" rel="external nofollow noopener noreferrer"&gt;RGB图像&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;具有三个通道 R、G、B，分别对应红、绿、蓝三个分量，由三个分量的值决定颜色；通常，会给RGB图像加一个通道alpha，即透明度，于是共有四个分量共同控制颜色。&lt;/p&gt;</description></item><item><title>Swift 开发者常犯的十大错误</title><link>https://apolla.cc/posts/tips/swift-%E5%BC%80%E5%8F%91%E8%80%85%E5%B8%B8%E7%8A%AF%E7%9A%84%E5%8D%81%E5%A4%A7%E9%94%99%E8%AF%AF/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/swift-%E5%BC%80%E5%8F%91%E8%80%85%E5%B8%B8%E7%8A%AF%E7%9A%84%E5%8D%81%E5%A4%A7%E9%94%99%E8%AF%AF/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/ecd61e61e9a4fe641373f1fcb12c8153.webp' alt="/images/ecd61e61e9a4fe641373f1fcb12c8153.webp"&gt;&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="-错误一"&gt;&lt;span&gt;❌ 错误一&lt;/span&gt;&#10; &lt;a href="#-%e9%94%99%e8%af%af%e4%b8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;blockquote&gt;&#10;&lt;p&gt;没有正确处理可选项。可选项在 Swift 中是一个强大的工具，但是不能正确处理它们 可能会导致运行时崩溃。在展开可选项之前，请确保始终检查 nil 值。 通常用 if-let 或者 guard-let 来检查 nil 值。&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>XCode15与iOS17!17.1 真机测试问题处理_xcode 真机测试</title><link>https://apolla.cc/posts/tips/xcode15%E4%B8%8Eios1717.1-%E7%9C%9F%E6%9C%BA%E6%B5%8B%E8%AF%95%E9%97%AE%E9%A2%98%E5%A4%84%E7%90%86_xcode-%E7%9C%9F%E6%9C%BA%E6%B5%8B%E8%AF%95/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/xcode15%E4%B8%8Eios1717.1-%E7%9C%9F%E6%9C%BA%E6%B5%8B%E8%AF%95%E9%97%AE%E9%A2%98%E5%A4%84%E7%90%86_xcode-%E7%9C%9F%E6%9C%BA%E6%B5%8B%E8%AF%95/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;XCode15与iOS17/17.1 真机测试问题处理，网上相关博客很多，摘录了如下实践后能起作用的地址如下：&#10;&lt;a href="https://www.jianshu.com/p/ed68ea57d667" target="_blank" rel="external nofollow noopener noreferrer"&gt;Xcode 15 报错处理 - 简书&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;&lt;a href="https://blog.csdn.net/ZhaiAlan/article/details/131564174" target="_blank" rel="external nofollow noopener noreferrer"&gt;iOS17版本适配-CSDN博客&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://www.6hu.cc/archives/208992.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;Xcode15适配-六虎&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>传输常见架构</title><link>https://apolla.cc/posts/media/%E4%BC%A0%E8%BE%93%E5%B8%B8%E8%A7%81%E6%9E%B6%E6%9E%84/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/media/%E4%BC%A0%E8%BE%93%E5%B8%B8%E8%A7%81%E6%9E%B6%E6%9E%84/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>&lt;h1 class="heading-element" id="流媒体转发"&gt;&lt;span&gt;流媒体转发&lt;/span&gt;&#10; &lt;a href="#%e6%b5%81%e5%aa%92%e4%bd%93%e8%bd%ac%e5%8f%91" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/476b2a43b0712754e31775de81f04377.png' alt="image.png"&gt;&#10;优点&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;支持百万级别以上客户端同时观看，可以存储回放&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;缺点&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;资源 带宽消耗大&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>从探索到实践，iOS动态库懒加载实录</title><link>https://apolla.cc/posts/tips/%E4%BB%8E%E6%8E%A2%E7%B4%A2%E5%88%B0%E5%AE%9E%E8%B7%B5ios%E5%8A%A8%E6%80%81%E5%BA%93%E6%87%92%E5%8A%A0%E8%BD%BD%E5%AE%9E%E5%BD%95/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/%E4%BB%8E%E6%8E%A2%E7%B4%A2%E5%88%B0%E5%AE%9E%E8%B7%B5ios%E5%8A%A8%E6%80%81%E5%BA%93%E6%87%92%E5%8A%A0%E8%BD%BD%E5%AE%9E%E5%BD%95/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;h2 class="heading-element" id="导读"&gt;&lt;span&gt;导读&lt;/span&gt;&#10; &lt;a href="#%e5%af%bc%e8%af%bb" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;业务功能只增不减，图片已无压缩空间，业务代码无法快速下线，一个历经10年，由2000万条指令、6万多个类构成的APP如何才能在业务迭代过程中实现启动优化与下载优化？&lt;/p&gt;</description></item><item><title>关于 App Store 苹果商店价格的那些事（历上最全版） - 掘金</title><link>https://apolla.cc/posts/tips/%E5%85%B3%E4%BA%8E-app-store-%E8%8B%B9%E6%9E%9C%E5%95%86%E5%BA%97%E4%BB%B7%E6%A0%BC%E7%9A%84%E9%82%A3%E4%BA%9B%E4%BA%8B%E5%8E%86%E4%B8%8A%E6%9C%80%E5%85%A8%E7%89%88-%E6%8E%98%E9%87%91/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/%E5%85%B3%E4%BA%8E-app-store-%E8%8B%B9%E6%9E%9C%E5%95%86%E5%BA%97%E4%BB%B7%E6%A0%BC%E7%9A%84%E9%82%A3%E4%BA%9B%E4%BA%8B%E5%8E%86%E4%B8%8A%E6%9C%80%E5%85%A8%E7%89%88-%E6%8E%98%E9%87%91/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;作者：iHTCboy&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="一前言"&gt;&lt;span&gt;一、前言&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;苹果 2022 年 12 月 6 日宣布 &lt;a href="https://link.juejin.cn/?target=https%3A%2F%2Fdeveloper.apple.com%2Fcn%2Fnews%2F%3Fid%3Dqzex35ch" target="_blank" rel="external nofollow noopener noreferrer"&gt;App Store 定价机制最重大升级，新增 700 个价格点&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;。小编当时的总结和分析：&lt;/p&gt;</description></item><item><title>火掌柜iOS端基于CocoaPods的组件二进制化实践</title><link>https://apolla.cc/posts/modularization/%E7%81%AB%E6%8E%8C%E6%9F%9Cios%E7%AB%AF%E5%9F%BA%E4%BA%8Ecocoapods%E7%9A%84%E7%BB%84%E4%BB%B6%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E5%AE%9E%E8%B7%B5/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/modularization/%E7%81%AB%E6%8E%8C%E6%9F%9Cios%E7%AB%AF%E5%9F%BA%E4%BA%8Ecocoapods%E7%9A%84%E7%BB%84%E4%BB%B6%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%96%E5%AE%9E%E8%B7%B5/</guid><category domain="https://apolla.cc/categories/%E7%BB%84%E4%BB%B6%E5%8C%96/">组件化</category><description>&lt;p&gt;火掌柜 iOS 客户端经过近两年的组件化推进，组件数量已经颇具规模，达到了近 100 个。随着组件数量和代码量越来越多，主工程的打包时间从最初的十几分钟，增加到了现在的四十分钟左右。依赖组件较多，改动相对频繁的上层业务组件，其发布时间也较为漫长。编译时长的困扰，已经明显影响了日常开发体验，同时也造成 CI pipeline 执行时间过长，在 runner 资源匮乏的情况下，不利于内部 CI 的推广。当前时间节点下，如何减少编译时长，已经成为开发团队较为迫切的需求。&lt;/p&gt;</description></item><item><title>美术宝组件化架构工程步骤</title><link>https://apolla.cc/posts/modularization/%E7%BE%8E%E6%9C%AF%E5%AE%9D%E7%BB%84%E4%BB%B6%E5%8C%96%E6%9E%B6%E6%9E%84%E5%B7%A5%E7%A8%8B%E6%AD%A5%E9%AA%A4/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/modularization/%E7%BE%8E%E6%9C%AF%E5%AE%9D%E7%BB%84%E4%BB%B6%E5%8C%96%E6%9E%B6%E6%9E%84%E5%B7%A5%E7%A8%8B%E6%AD%A5%E9%AA%A4/</guid><category domain="https://apolla.cc/categories/%E7%BB%84%E4%BB%B6%E5%8C%96/">组件化</category><description>&lt;p&gt;&lt;strong&gt;一、新建SPArt用于存储学习的各个仓库&lt;/strong&gt;&#10;&lt;a href="http://gitlab.meishubao.com/SPArt" target="_blank" rel="external nofollow noopener noreferrer"&gt;http://gitlab.meishubao.com/SPArt&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;&lt;strong&gt;1、准备仓库：&lt;/strong&gt;&#10;SPArtRepo：私有源podspec&#10;SPArtMainProject ：测试主工程&#10;SPArtCommon：通用层&#10;SPArtFoundation：基础层&lt;/p&gt;&#10;&lt;p&gt;&lt;img loading="lazy" src='https://apolla.cc/images/936306acc1dc98a8b268a7cac77ee05e.png' alt="image.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;2、创建SPArtMainProject项目&lt;/strong&gt;&#10;配置podfie&lt;/p&gt;</description></item><item><title>如何实现 iOS 16 带来的 Depth Effect 图片效果</title><link>https://apolla.cc/posts/tips/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0-ios-16-%E5%B8%A6%E6%9D%A5%E7%9A%84-depth-effect-%E5%9B%BE%E7%89%87%E6%95%88%E6%9E%9C/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0-ios-16-%E5%B8%A6%E6%9D%A5%E7%9A%84-depth-effect-%E5%9B%BE%E7%89%87%E6%95%88%E6%9E%9C/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;原文链接：&lt;a href="https://juejin.cn/post/7197608023430283319?" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://juejin.cn/post/7197608023430283319?&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 class="heading-element"&gt;&lt;span&gt;&lt;img loading="lazy" src='https://apolla.cc/images/e336e871a4ee473245e74bd4e4ff9faf.webp' alt="/images/e336e871a4ee473245e74bd4e4ff9faf.webp"&gt;&lt;/span&gt;&#10; &lt;a href="#" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;h2 class="heading-element" id="0x01-前言"&gt;&lt;span&gt;0x01 前言&lt;/span&gt;&#10; &lt;a href="#0x01-%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;iOS 16 系统为我们带来了比较惊艳的桌面锁屏效果：Depth Effect。它可以使用一张普通图片当背景，同时可以在适当的地方遮拦住部分桌面组件，形成一种景深的效果（如下图）。&#10;&lt;img loading="lazy" src='https://apolla.cc/images/8e12c15adf7940938287fda3a66c9392.webp' alt="/images/8e12c15adf7940938287fda3a66c9392.webp"&gt;&lt;/p&gt;</description></item><item><title>网络传输基础</title><link>https://apolla.cc/posts/media/%E7%BD%91%E7%BB%9C%E4%BC%A0%E8%BE%93%E5%9F%BA%E7%A1%80/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/media/%E7%BD%91%E7%BB%9C%E4%BC%A0%E8%BE%93%E5%9F%BA%E7%A1%80/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>&lt;h2 class="heading-element" id="前言"&gt;&lt;span&gt;&lt;strong&gt;前言&lt;/strong&gt;&lt;/span&gt;&#10; &lt;a href="#%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;网络层只把分组发送到目的主机，但是真正通信的并不是主机而是主机中的进程。传输层提供了进程间的逻辑通信，传输层向高层用户屏蔽了下面网络层的核心细节，使应用程序看起来像是在两个传输层实体之间有一条端到端的逻辑通信信道。&#10;&lt;strong&gt;1、UDP 和 TCP 的特点与区别&lt;/strong&gt;&#10;&lt;strong&gt;用户数据报协议 UDP（User Datagram Protocol）&lt;/strong&gt;&#10;是无连接的，尽最大可能交付，没有拥塞控制，面向报文（对于应用程序传下来的报文不合并也不拆分，只是添加 UDP 首部），支持一对一、一对多、多对一和多对多的交互通信。&#10;&lt;strong&gt;传输控制协议 TCP（Transmission Control Protocol）&lt;/strong&gt;&#10;是面向连接的，提供可靠交付，有流量控制，拥塞控制，提供全双工通信，面向字节流（把应用层传下来的报文看成字节流，把字节流组织成大小不等的数据块），每一条 TCP 连接只能是点对点的（一对一）。&lt;/p&gt;</description></item><item><title>音视频入门</title><link>https://apolla.cc/posts/media/%E9%9F%B3%E8%A7%86%E9%A2%91%E5%85%A5%E9%97%A8/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/media/%E9%9F%B3%E8%A7%86%E9%A2%91%E5%85%A5%E9%97%A8/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>&lt;h3 class="heading-element" id="一音视频处理流程"&gt;&lt;span&gt;一、音视频处理流程&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80%e9%9f%b3%e8%a7%86%e9%a2%91%e5%a4%84%e7%90%86%e6%b5%81%e7%a8%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;音视频通信是指将音频和视频数据从一个端点传输到另一个端点的过程。通常，音视频通信流程包括音视频采集、编码、传输、解码和渲染五个主要环节。下面是更详细的描述：&lt;/p&gt;</description></item><item><title>用 SwiftUI 实现 AI 聊天对话 app - iChatGPT</title><link>https://apolla.cc/posts/tips/%E7%94%A8-swiftui-%E5%AE%9E%E7%8E%B0-ai-%E8%81%8A%E5%A4%A9%E5%AF%B9%E8%AF%9D-app-ichatgpt/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/%E7%94%A8-swiftui-%E5%AE%9E%E7%8E%B0-ai-%E8%81%8A%E5%A4%A9%E5%AF%B9%E8%AF%9D-app-ichatgpt/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;p&gt;原文链接：&lt;a href="https://juejin.cn/post/7175051294808211512?" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://juejin.cn/post/7175051294808211512?&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;&lt;img loading="lazy" src='https://apolla.cc/images/a329416483353d5a68fbe869682195b3.webp' alt="/images/a329416483353d5a68fbe869682195b3.webp"&gt;&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="一前言"&gt;&lt;span&gt;一、前言&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;关于 ChatGPT 的话题，大家都不陌生，我们直入话题，因为 ChatGPT 目前限制中国访问服务，所以如果直接使用 ChatGPT 网页进行对话，还是不太方便。通过 ChatGPT SessionToken 就可以不限制网络访问，所以大家发挥想象力实现各种的聊天机器人、小程序，而原生 app 可能体验更好！所以就有了 iChatGPT！一款用 SwiftUI 实现的开源 ChatGPT app，欢迎大家关注和提 PR。&lt;/p&gt;</description></item><item><title>云音乐 Swift 混编 Module 化实践</title><link>https://apolla.cc/posts/tips/%E4%BA%91%E9%9F%B3%E4%B9%90-swift-%E6%B7%B7%E7%BC%96-module-%E5%8C%96%E5%AE%9E%E8%B7%B5/</link><pubDate>Sun, 10 Mar 2024 09:47:41 +0800</pubDate><guid>https://apolla.cc/posts/tips/%E4%BA%91%E9%9F%B3%E4%B9%90-swift-%E6%B7%B7%E7%BC%96-module-%E5%8C%96%E5%AE%9E%E8%B7%B5/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;hr&gt;&#10;&lt;p&gt;title: 云音乐 Swift 混编 Module 化实践&#10;date: 2024-03-10 00:16:26&#10;copyright: false&#10;author: 网易云音乐技术团队&#10;home: &lt;a href="https://juejin.cn/user/4265760847567016/posts" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://juejin.cn/user/4265760847567016/posts&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;origin: juejin&#10;url: &lt;a href="https://juejin.cn/post/7207269389474037817" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://juejin.cn/post/7207269389474037817&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;tag:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;iOS&#10;categories:&#10;description: 图片来自：unsplash.com 本文作者：冰川 背景 云音乐 iOS App 经历多年的迭代，&amp;hellip;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;hr&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;图片来自：&lt;a href="https://unsplash.com" target="_blank" rel="external nofollow noopener noreferrer"&gt;unsplash.com&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;br&gt;&#10;本文作者：冰川&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h2 class="heading-element" id="背景"&gt;&lt;span&gt;背景&lt;/span&gt;&#10; &lt;a href="#%e8%83%8c%e6%99%af" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;云音乐 iOS App 经历多年的迭代，积累了大量的 Objective-C（以下简称 OC） 代码，目前已经完成主工程壳化，各层组件关系如下：&lt;/p&gt;</description></item><item><title>1 ：蓝牙连接流程</title><link>https://apolla.cc/posts/bluetooth/1-%E8%93%9D%E7%89%99%E8%BF%9E%E6%8E%A5%E6%B5%81%E7%A8%8B/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/1-%E8%93%9D%E7%89%99%E8%BF%9E%E6%8E%A5%E6%B5%81%E7%A8%8B/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;p&gt;iOS系统中总共提供了4个框架用于实现蓝牙连接，分别如下：&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;1.GameKit.framework(用法简单) 只能用于iOS设备之间的同个应用内连接,多用于游戏(如:棋牌类),从iOS7开始过期&#10;2.MultipeerConnectivity.framework(代替GameKit.framework) 只能用于iOS设备之间的连接,从iOS7开始引入,主要用于非联网状态下,通过wifi或者蓝牙进行文件共享(仅限于沙盒的文件),多用于附近无网聊天&#10;3.ExternalAccessory.framework(MFi) 可用于第三方蓝牙设备交互,但是蓝牙设备必须经过苹果MFi认证&#10;4.CoreBluetooth.framework（常用 Apple推行蓝牙的核心)可用于第三方蓝牙设备交互,必须要支持蓝牙4.0。硬件至少是4s,系统至少是iOS6。蓝牙4.0以低功耗著称,一般也叫BLE（Bluetooth Low Energy）&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>14： ijkplayer阅读笔记</title><link>https://apolla.cc/posts/live/14-ijkplayer%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/live/14-ijkplayer%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;读取视频包 &amp;mdash;&amp;mdash;&amp;gt; 解码 &amp;mdash;&amp;mdash;&amp;gt; 显示&lt;/p&gt;&#10;&lt;p&gt;视频流程：&lt;/p&gt;&#10;&lt;p&gt;1)读取线程：读取视频包，推入videoq队列中&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;read_thread{&#10; ret = stream_component_open(ffp, st_index[AVMEDIA_TYPE_VIDEO]);{&#10; is-&amp;gt;video_tid = SDL_CreateThreadEx(&amp;amp;is-&amp;gt;_video_tid, video_thread, ffp, &amp;#34;ff_video_dec&amp;#34;);&#10; }&#10; &#10; for (;;) {&#10; if (is-&amp;gt;abort_request)&#10; break;&#10; &#10; ret = av_read_frame(ic, pkt);&#10; packet_queue_put(&amp;amp;is-&amp;gt;videoq, pkt); //将获取到的视频包推入videoq队列中&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;2）解码线程&#10;软解：从videoq队列中获取视频包，解码视频帧放入pictq列表中&#10;硬解：从videoq队列中获取视频包，推送MediaCodec解码，获取解码outputbuffer index并存储在pictq列表中&lt;/p&gt;</description></item><item><title>17： MPMoviePlayerViewController</title><link>https://apolla.cc/posts/live/17-mpmovieplayerviewcontroller/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/live/17-mpmovieplayerviewcontroller/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;MPMoviePlayerViewController 解释：视频播放器&lt;/p&gt;&#10;&lt;p&gt;iOS开发中播放音乐可以使用MPMusicPlayerController类来实现，播放视频可以使用MPMoviePlayerController和MPMoviePlayerViewController类来实现，MPMediaPickerController类可以用于从系统媒体库中选择媒体播放。这几个类都包含与MediaPlayer.framework框架中。&lt;/p&gt;</description></item><item><title>2：蓝牙常用API</title><link>https://apolla.cc/posts/bluetooth/2%E8%93%9D%E7%89%99%E5%B8%B8%E7%94%A8api/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/2%E8%93%9D%E7%89%99%E5%B8%B8%E7%94%A8api/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;p&gt;上篇讲了蓝牙相关的基本概念，现在结合代码讲讲具体实现。首先需要创建一个CBCentralManager对象，检查蓝牙的状态，只有蓝牙为poweredOn状态，才可进行下一步连接动作。&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="cbcentralmanager-初始化"&gt;&lt;span&gt;CBCentralManager 初始化&lt;/span&gt;&#10; &lt;a href="#cbcentralmanager-%e5%88%9d%e5%a7%8b%e5%8c%96" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;//先导入`CoreBluetooth` 框架&#10; var centralManager: CBCentralManager!&#10; //设置deleagte、queue、可选参数options，options可以为nil,也可设置CBCentralManagerOptionShowPowerAlertKey蓝牙提醒弹窗和CBCentralManagerOptionRestoreIdentifierKey字符串(一个唯一的标识符，用来恢复蓝牙连接的，在后台的长连接中可能用到)&#10; override init() {&#10; super.init()&#10; &#10; self.centralManager = CBCentralManager(delegate: self, queue: nil)&#10; }&#10; &#10; init(stateRestoreIdentifier: String) {&#10; super.init()&#10; &#10; self.centralManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionRestoreIdentifierKey: stateRestoreIdentifier])&#10; }&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="主要api的使用"&gt;&lt;span&gt;主要API的使用&lt;/span&gt;&#10; &lt;a href="#%e4%b8%bb%e8%a6%81api%e7%9a%84%e4%bd%bf%e7%94%a8" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;pre&gt;&lt;code&gt; // 获取已连接的设备&#10; open func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBUUID]) -&amp;gt; [CBPeripheral]&#10; // 扫描设备(serviceUUIDs:需要扫描的设备serviceUUID数组，设置为nil,则扫描附近所有蓝牙设备，通常为了提高效率，填入特定的serviceUUID数组)&#10; open func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil)&#10; // 停止扫描&#10; open func stopScan()&#10; // 连接设备&#10; open func connect(_ peripheral: CBPeripheral, options: [String : Any]? = nil)&#10; // 断开连接&#10; open func cancelPeripheralConnection(_ peripheral: CBPeripheral)&lt;/code&gt;&lt;/pre&gt;&lt;h3 class="heading-element" id="cbcentralmanagerdelegate的回调"&gt;&lt;span&gt;CBCentralManagerDelegate的回调&lt;/span&gt;&#10; &lt;a href="#cbcentralmanagerdelegate%e7%9a%84%e5%9b%9e%e8%b0%83" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;pre&gt;&lt;code&gt;// 蓝牙状态变更&#10; func centralManagerDidUpdateState(_ central: CBCentralManager) {&#10; switch central.state.rawValue {&#10; case 0: // .unknown&#10; &#10; case 1: // .resetting&#10; &#10; case 2: // .unsupported&#10; &#10; case 3: // .unauthorized&#10; &#10; case 4: // .poweredOff(蓝牙关闭)&#10; &#10; case 5: // .poweredOn(蓝牙打开)&#10; &#10; default:&#10; fatalError(&amp;#34;Unsupported BLE CentralState&amp;#34;)&#10; }&#10; }&#10;&#10;// 扫描到设备 advertisementData：广播包数据 RSSI：信号强度&#10; func centralManager(_ central: CBCentralManager,&#10; didDiscover peripheral: CBPeripheral,&#10; advertisementData: [String: Any],&#10; rssi RSSI: NSNumber) {&#10; &#10; }&#10;// 设备成功连接&#10; func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {&#10; &#10; }&#10;&#10;// 设备连接失败&#10;optional func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {&#10;&#10;}&#10;// 设备连接断开&#10; func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {&#10;&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;与设备连接成功后，会生成一个CBPeripheral对象，用来操作设备数据的读写和监听等。&lt;/p&gt;</description></item><item><title>3： RTMP直播应用与延时分析</title><link>https://apolla.cc/posts/live/3-rtmp%E7%9B%B4%E6%92%AD%E5%BA%94%E7%94%A8%E4%B8%8E%E5%BB%B6%E6%97%B6%E5%88%86%E6%9E%90/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/live/3-rtmp%E7%9B%B4%E6%92%AD%E5%BA%94%E7%94%A8%E4%B8%8E%E5%BB%B6%E6%97%B6%E5%88%86%E6%9E%90/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;直播应用中，RTMP和HLS基本上可以覆盖所有客户端观看&#10;HLS主要是延时比较大，RTMP主要优势在于延时低。&lt;/p&gt;&#10;&lt;p&gt;一、应用场景&#10;◊ 低延时应用场景包括：&#10;◊ 互动式直播：譬如2013年大行其道的美女主播，游戏直播等等&#10;◊ 各种主播，流媒体分发给用户观看。用户可以文字聊天和主播互动。&#10;◊ 视频会议：我们要是有同事出差在外地，就用视频会议开内部会议。&#10;◊ 其实会议1秒延时无所谓，因为人家讲完话后，其他人需要思考，&#10;◊ 思考的延时也会在1秒左右。当然如果用视频会议吵架就不行。&#10;◊ 其他：监控，直播也有些地方需要对延迟有要求，&#10;◊ 互联网上RTMP协议的延迟基本上能够满足要求。&lt;/p&gt;</description></item><item><title>3：Mac地址的获取及写入指令的处理</title><link>https://apolla.cc/posts/bluetooth/3mac%E5%9C%B0%E5%9D%80%E7%9A%84%E8%8E%B7%E5%8F%96%E5%8F%8A%E5%86%99%E5%85%A5%E6%8C%87%E4%BB%A4%E7%9A%84%E5%A4%84%E7%90%86/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/3mac%E5%9C%B0%E5%9D%80%E7%9A%84%E8%8E%B7%E5%8F%96%E5%8F%8A%E5%86%99%E5%85%A5%E6%8C%87%E4%BB%A4%E7%9A%84%E5%A4%84%E7%90%86/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;h2 class="heading-element" id="mac地址的获取"&gt;&lt;span&gt;Mac地址的获取&lt;/span&gt;&#10; &lt;a href="#mac%e5%9c%b0%e5%9d%80%e7%9a%84%e8%8e%b7%e5%8f%96" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;iOS7之后，苹果不支持获取Mac地址，只能用UUID来标识设备。若想获得Mac地址，可以跟硬件工程师沟通，增加一个指令获取，也可以让硬件工程师把Mac地址写到广播包里，在扫描的时候获取Mac地址，如下所示：&lt;/p&gt;</description></item><item><title>5：蓝牙固件升级</title><link>https://apolla.cc/posts/bluetooth/5%E8%93%9D%E7%89%99%E5%9B%BA%E4%BB%B6%E5%8D%87%E7%BA%A7/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/5%E8%93%9D%E7%89%99%E5%9B%BA%E4%BB%B6%E5%8D%87%E7%BA%A7/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;h1 class="heading-element" id="一为何要升级"&gt;&lt;span&gt;一.为何要升级&lt;/span&gt;&#10; &lt;a href="#%e4%b8%80%e4%b8%ba%e4%bd%95%e8%a6%81%e5%8d%87%e7%ba%a7" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;blockquote&gt;&#10;&lt;p&gt;蓝牙固件升级是使用手机给固件进行更新，以达到修复bug的目的，完善功能的作用。升级的大概流程是：&#10;1.当蓝牙设备的固件需要升级时，由嵌入式开发人员提供新的固件，由服务器管理人员将固件放到服务器上。&#10;2.用户打开手机 APP 的时候会检测到服务器有更新，请求更新蓝牙设备固件，确认更新后，手机会从服务器下载固件。&#10;3.下载完毕后，APP 会读取固件内容，并根据升级协议将内容传到蓝牙设备里，完成升级。&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>6：SwiftyBluetooth的使用</title><link>https://apolla.cc/posts/bluetooth/6swiftybluetooth%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/bluetooth/6swiftybluetooth%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/%E8%93%9D%E7%89%99/">蓝牙</category><description>&lt;h1 class="heading-element" id="简介"&gt;&lt;span&gt;简介&lt;/span&gt;&#10; &lt;a href="#%e7%ae%80%e4%bb%8b" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;&lt;code&gt;SwiftyBluetooth&lt;/code&gt;是&lt;code&gt;Swift&lt;/code&gt;中封装&lt;code&gt;CoreBluetooth&lt;/code&gt;框架的一个开源库&lt;a href="https://link.juejin.cn?target=https%3A%2F%2Fgithub.com%2Fjordanebelanger%2FSwiftyBluetooth" target="_blank" rel="external nofollow noopener noreferrer"&gt;SwiftyBluetooth&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;,个人觉得比较好用，是对&lt;code&gt;CoreBluetooth&lt;/code&gt;的封装，可自行查看代码，下面来讲讲它的使用。&lt;/p&gt;</description></item><item><title>6：推荐的直播文章和rtmp直播地址</title><link>https://apolla.cc/posts/live/6%E6%8E%A8%E8%8D%90%E7%9A%84%E7%9B%B4%E6%92%AD%E6%96%87%E7%AB%A0%E5%92%8Crtmp%E7%9B%B4%E6%92%AD%E5%9C%B0%E5%9D%80/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/live/6%E6%8E%A8%E8%8D%90%E7%9A%84%E7%9B%B4%E6%92%AD%E6%96%87%E7%AB%A0%E5%92%8Crtmp%E7%9B%B4%E6%92%AD%E5%9C%B0%E5%9D%80/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;ul&gt;&#10;&lt;li&gt;解读：&lt;a href="http://blog.sina.com.cn/s/blog_4ad042e50100ijcq.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;X264和H264 是什么？&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://bbs.9ria.com/thread-110484-1-1.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;rtmp和http方式在播放flv方面的各自优势和劣势&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://www.cnblogs.com/qingquan/archive/2011/07/27/2118967.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;I,P，B帧和PTS，DTS的关系&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://weibo.com/ttarticle/p/show?id=2309403969318634263193" target="_blank" rel="external nofollow noopener noreferrer"&gt;移动直播技术秒开优化经验(超级重要，必读！)&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://www.jianshu.com/p/b78db64acd77" target="_blank" rel="external nofollow noopener noreferrer"&gt;iOS8系统H264视频硬件编解码说明&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="http://www.videolan.org/developers/x264.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;download x264&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://blog.csdn.net/leixiaohua1020/article/details/38283297" target="_blank" rel="external nofollow noopener noreferrer"&gt;FFmpeg发送流媒体的命令（UDP，RTP，RTMP）&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://blog.csdn.net/leixiaohua1020/article/details/38283297" target="_blank" rel="external nofollow noopener noreferrer"&gt;FFmpeg官网&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://blog.csdn.net/leixiaohua1020/article/details/15811977/" target="_blank" rel="external nofollow noopener noreferrer"&gt;FFMPEG视音频编解码零基础学习方法（最权威推荐阅读）&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="http://www.videolan.org/developers/x264.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;download x264&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;GitHub -&amp;gt; &lt;a href="https://github.com/jgh-" target="_blank" rel="external nofollow noopener noreferrer"&gt;jgh-&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;/&lt;a href="https://github.com/jgh-/VideoCore" target="_blank" rel="external nofollow noopener noreferrer"&gt;VideoCore&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;**GitHub -&amp;gt; &lt;a href="https://github.com/runner365" target="_blank" rel="external nofollow noopener noreferrer"&gt;runner365&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;/&lt;a href="https://github.com/runner365/LiveVideoCoreSDK" target="_blank" rel="external nofollow noopener noreferrer"&gt;LiveVideoCoreSDK&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://www.cnblogs.com/haibindev/archive/2013/01/30/2880764.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;HTTP Live Streaming直播(iOS直播)技术分析与实现&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;GitHub -&amp;gt; &lt;a href="https://github.com/LaiFengiOS" target="_blank" rel="external nofollow noopener noreferrer"&gt;LaiFengiOS&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;/&lt;a href="https://github.com/LaiFengiOS/LFLiveKit" target="_blank" rel="external nofollow noopener noreferrer"&gt;LFLiveKit&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;**GitHub -&amp;gt; &lt;a href="https://github.com/BradLarson" target="_blank" rel="external nofollow noopener noreferrer"&gt;BradLarson&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;/&lt;a href="https://github.com/BradLarson/GPUImage" target="_blank" rel="external nofollow noopener noreferrer"&gt;GPUImage&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;**GitHub -&amp;gt; &lt;a href="https://github.com/Guikunzhi/BeautifyFaceDemo" target="_blank" rel="external nofollow noopener noreferrer"&gt;BeautifyFaceDemo&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;解读：&lt;a href="http://www.open-open.com/lib/view/open1463108934371.html" target="_blank" rel="external nofollow noopener noreferrer"&gt;iOS实时美颜滤镜是怎样炼成的&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&#10;GitHub -&amp;gt; &lt;a href="https://github.com/Bilibili" target="_blank" rel="external nofollow noopener noreferrer"&gt;Bilibili&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;/&lt;a href="https://github.com/Bilibili/ijkplayer" target="_blank" rel="external nofollow noopener noreferrer"&gt;ijkplayer&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;一般做rtmp编程的时候，需要用到rtmp视频源地址，通常可以自己搭建Red5等服务器到自己的机器配置好后，编写客户端，但是这样有点麻烦；&lt;/p&gt;</description></item><item><title>8：FFmpeg在iOS上完美编译</title><link>https://apolla.cc/posts/live/8ffmpeg%E5%9C%A8ios%E4%B8%8A%E5%AE%8C%E7%BE%8E%E7%BC%96%E8%AF%91/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/live/8ffmpeg%E5%9C%A8ios%E4%B8%8A%E5%AE%8C%E7%BE%8E%E7%BC%96%E8%AF%91/</guid><category domain="https://apolla.cc/categories/%E7%9B%B4%E6%92%AD/">直播</category><description>&lt;p&gt;最近刚接触ffmpeg,找了很多相关的编译资料，都没有编译成功，前几天在 github上找到一个脚本（&lt;a href="https://github.com/kewlbear/FFmpeg-iOS-build-script" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://github.com/kewlbear/FFmpeg-iOS-build-script&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;），就可完美编译&#10;&lt;strong&gt;准备条件&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;先下载文件：&lt;a href="https://github.com/libav/gas-preprocessor" target="_blank" rel="external nofollow noopener noreferrer"&gt;https://github.com/libav/gas-preprocessor&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;，&#10;复制gas-preprocessor.pl到/usr/sbin下，&#10;修改文件权限：chmod 777 /usr/local/bin/gas-preprocessor.pl&lt;/li&gt;&#10;&lt;li&gt;安装yasm&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;&lt;strong&gt;具体步骤如下：&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>FFmpeg编译</title><link>https://apolla.cc/posts/media/ffmpeg%E7%BC%96%E8%AF%91/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/media/ffmpeg%E7%BC%96%E8%AF%91/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>FFmpeg编译</description></item><item><title>iOS 电脑WiFi传输文件到iphone</title><link>https://apolla.cc/posts/reading/ios-%E7%94%B5%E8%84%91wifi%E4%BC%A0%E8%BE%93%E6%96%87%E4%BB%B6%E5%88%B0iphone/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios-%E7%94%B5%E8%84%91wifi%E4%BC%A0%E8%BE%93%E6%96%87%E4%BB%B6%E5%88%B0iphone/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;p&gt;##1.前言&lt;/p&gt;&#10;&lt;p&gt;这个功能早已开发好，但是博客为什么今天才更新，说起来一把鼻涕一把泪，我的小说APP更新提审遭遇了各种悲剧性的问题，关键词违规，内容被认为包含色情等待，就是那部 《我的绝色房东》审核人员打开的正好是这本，这半个月天天和审核人员勾心斗角，目前就剩下一个4.2.2 最低功能要求死活过不去，我明明是更新啊！！！&lt;/p&gt;</description></item><item><title>iOS 获取图片、区域的主色。水印文字颜色处理,主要方法来自其他文档，自己再修改整合</title><link>https://apolla.cc/posts/tips/ios-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E5%8C%BA%E5%9F%9F%E7%9A%84%E4%B8%BB%E8%89%B2%E6%B0%B4%E5%8D%B0%E6%96%87%E5%AD%97%E9%A2%9C%E8%89%B2%E5%A4%84%E7%90%86%E4%B8%BB%E8%A6%81%E6%96%B9%E6%B3%95%E6%9D%A5%E8%87%AA%E5%85%B6%E4%BB%96%E6%96%87%E6%A1%A3%E8%87%AA%E5%B7%B1%E5%86%8D%E4%BF%AE%E6%94%B9%E6%95%B4%E5%90%88/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/tips/ios-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E5%8C%BA%E5%9F%9F%E7%9A%84%E4%B8%BB%E8%89%B2%E6%B0%B4%E5%8D%B0%E6%96%87%E5%AD%97%E9%A2%9C%E8%89%B2%E5%A4%84%E7%90%86%E4%B8%BB%E8%A6%81%E6%96%B9%E6%B3%95%E6%9D%A5%E8%87%AA%E5%85%B6%E4%BB%96%E6%96%87%E6%A1%A3%E8%87%AA%E5%B7%B1%E5%86%8D%E4%BF%AE%E6%94%B9%E6%95%B4%E5%90%88/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;pre&gt;&lt;code&gt;//添加水印&#10;&amp;#43; (UIImage *)getWaterMarkWith:(UIImage *)image waterText:(NSString *)str{&#10;&#10; CGSize imageSize = image.size;&#10; CGFloat imageWidth = imageSize.width;&#10; CGFloat imageHeight = imageSize.height;&#10;&#10; UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);&#10; [image drawAtPoint:CGPointZero];&#10; CGFloat textFont = 10 * ceilf(imageWidth / [UIScreen mainScreen].bounds.size.width);&#10; CGSize perSize = [self getSize:imageWidth font:[UIFont systemFontOfSize:textFont] str:str lineSpace:0];&#10; CGRect rect = CGRectMake(ceilf(imageWidth - perSize.width - 20),&#10; ceilf(imageHeight - perSize.height - 20),&#10; ceilf(perSize.width &amp;#43; 10),&#10; ceilf(perSize.height &amp;#43; 5));&#10;&#10; NSDictionary *colorInfo = [self mostColor:image scale:1 rect:rect];&#10; CGFloat red = [colorInfo[@&amp;#34;red&amp;#34;] floatValue];&#10; CGFloat green = [colorInfo[@&amp;#34;green&amp;#34;] floatValue];&#10; CGFloat blue = [colorInfo[@&amp;#34;blue&amp;#34;] floatValue];&#10; CGFloat alpha = [colorInfo[@&amp;#34;alpha&amp;#34;] floatValue];&#10; BOOL colorDark = [self isDarkColor:[UIColor colorWithRed:red green:green blue:blue alpha:alpha]];&#10; [str drawAtPoint:rect.origin withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:textFont], NSForegroundColorAttributeName:colorDark ? [UIColor whiteColor] : [UIColor blackColor]}];&#10; image = UIGraphicsGetImageFromCurrentImageContext();&#10; UIGraphicsEndImageContext();&#10;&#10; return image;&#10;}&#10;&#10;// 获取图片、区域的主色&#10;&amp;#43; (NSDictionary *)mostColor:(UIImage *)image scale:(CGFloat)scale rect:(CGRect)rect{&#10;&#10; #if __IPHONE_OS_VERSION_MAX_ALLOWED &amp;gt; __IPHONE_6_1&#10; int bitmapInfo = kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast;&#10; #else&#10; int bitmapInfo = kCGImageAlphaPremultipliedLast;&#10; #endif&#10; if (scale &amp;lt;= 0.1) {&#10; scale = 0.1;&#10; }else if(scale &amp;gt;= 1){&#10; scale = 1;&#10; }&#10;&#10; if (rect.size.width &amp;gt; 0 &amp;amp;&amp;amp; rect.size.height &amp;gt; 0) {&#10; image = [self cropSquareImage:image rect:rect];&#10; }&#10;&#10; //第一步 先把图片缩小 加快计算速度. 但越小结果误差可能越大&#10; CGSize thumbSize = CGSizeMake([image size].width * scale, [image size].height * scale);&#10; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();&#10; CGContextRef context = CGBitmapContextCreate(NULL,&#10; thumbSize.width,&#10; thumbSize.height,&#10; 8,//bits per component&#10; thumbSize.width*4,&#10; colorSpace,&#10; bitmapInfo);&#10;&#10; CGRect drawRect = CGRectMake(0, 0, thumbSize.width, thumbSize.height);&#10; CGContextDrawImage(context, drawRect, image.CGImage);&#10; CGColorSpaceRelease(colorSpace);&#10;&#10; //第二步 取每个点的像素值&#10; unsigned char* data = CGBitmapContextGetData (context);&#10;&#10; if (data == NULL){&#10; CGContextRelease(context);&#10; return nil;&#10; }&#10;&#10; NSCountedSet *cls = [NSCountedSet setWithCapacity:thumbSize.width*thumbSize.height];&#10;&#10; for (int x=0; x&amp;lt;thumbSize.height; x&amp;#43;&amp;#43;) {&#10; for (int y=0; y&amp;lt;thumbSize.width; y&amp;#43;&amp;#43;) {&#10; int offset = 4*(x*thumbSize.width &amp;#43; y);&#10; int red = data[offset];&#10; int green = data[offset&amp;#43;1];&#10; int blue = data[offset&amp;#43;2];&#10; int alpha = data[offset&amp;#43;3];&#10;&#10; NSArray *clr=@[@(red),@(green),@(blue),@(alpha)];&#10; [cls addObject:clr];&#10; }&#10; }&#10; CGContextRelease(context);&#10;&#10; //第三步 找到出现次数最多的那个颜色&#10; NSEnumerator *enumerator = [cls objectEnumerator];&#10; NSArray *curColor = nil;&#10;&#10; NSArray *MaxColor=nil;&#10; NSUInteger MaxCount=0;&#10;&#10; while ( (curColor = [enumerator nextObject]) != nil ){&#10; NSUInteger tmpCount = [cls countForObject:curColor];&#10; if ( tmpCount &amp;lt; MaxCount ) continue;&#10; MaxCount=tmpCount;&#10; MaxColor=curColor;&#10; }&#10; //返回三色值&amp;#43;透明度&#10; NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithCapacity:0];&#10; [dic setValue:@([MaxColor[0] intValue]/255.0f) forKey:@&amp;#34;red&amp;#34;];&#10; [dic setValue:@([MaxColor[1] intValue]/255.0f) forKey:@&amp;#34;green&amp;#34;];&#10; [dic setValue:@([MaxColor[2] intValue]/255.0f) forKey:@&amp;#34;blue&amp;#34;];&#10; [dic setValue:@([MaxColor[3] intValue]/255.0f) forKey:@&amp;#34;alpha&amp;#34;];&#10; return dic;&#10;}&#10; //裁剪图片&#10; &amp;#43; (UIImage *)cropSquareImage:(UIImage *)image rect:(CGRect)rect{&#10; CGImageRef sourceImageRef = [image CGImage];&#10; CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, rect);&#10; UIImage *newImage = [UIImage imageWithCGImage:newImageRef];&#10; return newImage;&#10;}&#10;&#10;&#10; //判断颜色深浅&#10; &amp;#43; (BOOL)isDarkColor:(UIColor *)newColor{&#10; const CGFloat *componentColors = CGColorGetComponents(newColor.CGColor);&#10; CGFloat colorBrightness = ((componentColors[0] * 299) &amp;#43; (componentColors[1] * 587) &amp;#43; (componentColors[2] * 114)) / 1000;&#10; if (colorBrightness &amp;lt; 0.5){&#10; //深色&#10; return YES;&#10; } else{&#10; //浅色&#10; return NO;&#10; }&#10;}&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>iOS 跳转App Store进行评分</title><link>https://apolla.cc/posts/reading/ios-%E8%B7%B3%E8%BD%ACapp-store%E8%BF%9B%E8%A1%8C%E8%AF%84%E5%88%86/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios-%E8%B7%B3%E8%BD%ACapp-store%E8%BF%9B%E8%A1%8C%E8%AF%84%E5%88%86/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;h2 class="heading-element" id="1前言"&gt;&lt;span&gt;1.前言&lt;/span&gt;&#10; &lt;a href="#1%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;遭遇4.2.2把我逼得没办法了，啥功能都怼上去了&lt;/p&gt;&#10;&lt;h2 class="heading-element" id="2实现"&gt;&lt;span&gt;2.实现&lt;/span&gt;&#10; &lt;a href="#2%e5%ae%9e%e7%8e%b0" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;在 viewdidload 或者 viewwillappear 中判断是否需要显示评分，因为SKStoreReviewController 一年最多三次，所以我就无耻点相隔四个月调用一次&lt;/p&gt;</description></item><item><title>iOS 针对txt文档进行解码</title><link>https://apolla.cc/posts/reading/ios-%E9%92%88%E5%AF%B9txt%E6%96%87%E6%A1%A3%E8%BF%9B%E8%A1%8C%E8%A7%A3%E7%A0%81/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios-%E9%92%88%E5%AF%B9txt%E6%96%87%E6%A1%A3%E8%BF%9B%E8%A1%8C%E8%A7%A3%E7%A0%81/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;p&gt;如我上一篇文章记录，我加了打开其他APPtxt文件的小功能，紧接着碰到新问题了，我在测试过程中发现用户上传的TXT编码格式很多不单单是utf-8和gb2312,针对TXT文档进行解码，我一共经历过两个阶段，如下&lt;/p&gt;&#10;&lt;p&gt;##1.通过循环 解码不为空就返回字符串&lt;/p&gt;</description></item><item><title>iOS基于AVFoundation实现朗读文字</title><link>https://apolla.cc/posts/reading/ios%E5%9F%BA%E4%BA%8Eavfoundation%E5%AE%9E%E7%8E%B0%E6%9C%97%E8%AF%BB%E6%96%87%E5%AD%97/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios%E5%9F%BA%E4%BA%8Eavfoundation%E5%AE%9E%E7%8E%B0%E6%9C%97%E8%AF%BB%E6%96%87%E5%AD%97/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;p&gt;##1.心理建设&lt;/p&gt;&#10;&lt;p&gt;众所周知AVFoundation的朗读是个智障语气，所以想不花钱就只能忍着。&lt;/p&gt;&#10;&lt;p&gt;##2.speechManager&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;@import AVFoundation;&#10;&#10;@protocol TJSpeechManagerDelegate &amp;lt;NSObject&amp;gt;&#10;@optional&#10;- (void)didStartSpeechUtterance:(AVSpeechUtterance*)utterance;&#10;- (void)didFinishSpeechUtterance:(AVSpeechUtterance*)utterance;&#10;- (void)didPauseSpeechUtterance:(AVSpeechUtterance*)utterance;&#10;- (void)didCancelSpeechUtterance:(AVSpeechUtterance*)utterance;&#10;- (void)willSpeakRangeOfSpeechString:(NSRange)characterRange utterance:(AVSpeechUtterance *)utterance;&#10;&#10;- (void)needRepeatSpeech:(AVSpeechUtterance *)utterance;&#10;@end&#10;&#10;@interface TJSpeechManager : NSObject &amp;lt;AVSpeechSynthesizerDelegate&amp;gt;&#10;&#10;&#10;@property (nonatomic, strong) AVSpeechSynthesizer *avSpeech;&#10;@property (nonatomic, strong) AVSpeechUtterance *speechUtt;&#10;&#10;@property (nonatomic, assign) id &amp;lt;TJSpeechManagerDelegate&amp;gt; delegate;&#10;&#10;&#10;- (void)setSpeechContent:(NSString *)content;&#10;&#10;&#10;- (void)pauseSpeech;&#10;&#10;&#10;- (void)beginSpeech;&#10;&#10;- (void)continueSpeech;&#10;&#10;- (void)endSpeech;&#10;&#10;@end&#10;&#10;&#10;#import &amp;#34;TJSpeechManager.h&amp;#34;&#10;&#10;@implementation TJSpeechManager&#10;&#10;- (void)setSpeechContent:(NSString *)content {&#10; AVSpeechUtterance *speechUtt = [AVSpeechUtterance speechUtteranceWithString:content];&#10; speechUtt.rate = 0.5;&#10; speechUtt.pitchMultiplier = 1;&#10; &#10; //设置音量,[0-1] 默认 = 1&#10; speechUtt.volume = 1;&#10;&#10; //读一段前的停顿时间&#10; speechUtt.preUtteranceDelay = 1;&#10; //读完一段后的停顿时间&#10; speechUtt.postUtteranceDelay = 1;&#10; AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@&amp;#34;zh-CN&amp;#34;];&#10; speechUtt.voice = voice;&#10; self.speechUtt = speechUtt;&#10;}&#10;&#10;- (void)beginSpeech {&#10; //这里需要注意一下，一个avspeech对象只能播放一次，同一个对象中途不能重新播放。&#10; AVSpeechSynthesizer *avSpeech = [[AVSpeechSynthesizer alloc] init];&#10; avSpeech.delegate = self;&#10; [avSpeech speakUtterance:self.speechUtt];&#10; self.avSpeech = avSpeech;&#10;}&#10;&#10;- (void)pauseSpeech {&#10; [self.avSpeech pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];&#10;}&#10;&#10;- (void)continueSpeech {&#10; if(self.avSpeech.isPaused) {&#10; [self.avSpeech continueSpeaking];&#10; [NSThread sleepForTimeInterval:0.25f];&#10; }&#10;}&#10;&#10;- (void)endSpeech {&#10; if(self.avSpeech.isSpeaking) {&#10; [self.avSpeech stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];&#10; [NSThread sleepForTimeInterval:0.25f];&#10; }&#10;}&#10;&#10;//代理主要是返回给controller，用来和UI交互&#10;#pragma mark - AVSpeechSynthesizerDelegate;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer*)synthesizer didStartSpeechUtterance:(AVSpeechUtterance*)utterance{&#10; NSLog(@&amp;#34;---开始播放&amp;#34;);&#10; if(self.delegate &amp;amp;&amp;amp; [self.delegate respondsToSelector:@selector(didStartSpeechUtterance:)]) {&#10; [self.delegate didStartSpeechUtterance:utterance];&#10; }&#10;}&#10;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer*)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance*)utterance{&#10; NSLog(@&amp;#34;---完成播放&amp;#34;);&#10; if(self.delegate &amp;amp;&amp;amp; [self.delegate respondsToSelector:@selector(didFinishSpeechUtterance:)]) {&#10; [self.delegate didFinishSpeechUtterance:utterance];&#10; }&#10;}&#10;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer*)synthesizer didPauseSpeechUtterance:(AVSpeechUtterance*)utterance{&#10; NSLog(@&amp;#34;---播放中止&amp;#34;);&#10; if(self.delegate &amp;amp;&amp;amp; [self.delegate respondsToSelector:@selector(didPauseSpeechUtterance:)]) {&#10; [self.delegate didPauseSpeechUtterance:utterance];&#10; }&#10;}&#10;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer*)synthesizer didContinueSpeechUtterance:(AVSpeechUtterance*)utterance{&#10; NSLog(@&amp;#34;---恢复播放&amp;#34;);&#10; &#10;}&#10;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer*)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance*)utterance{&#10; NSLog(@&amp;#34;---播放取消&amp;#34;);&#10; if(self.delegate &amp;amp;&amp;amp; [self.delegate respondsToSelector:@selector(didCancelSpeechUtterance:)]) {&#10; [self.delegate didCancelSpeechUtterance:utterance];&#10; }&#10;}&#10;&#10;- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer willSpeakRangeOfSpeechString:(NSRange)characterRange utterance:(AVSpeechUtterance *)utterance {&#10; if(self.delegate &amp;amp;&amp;amp; [self.delegate respondsToSelector:@selector(willSpeakRangeOfSpeechString:utterance:)]) {&#10; [self.delegate willSpeakRangeOfSpeechString:characterRange utterance:utterance];&#10; }&#10;}&#10;&#10;@end&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;##3.使用范例&lt;/p&gt;</description></item><item><title>ios解析txt电子书</title><link>https://apolla.cc/posts/reading/ios%E8%A7%A3%E6%9E%90txt%E7%94%B5%E5%AD%90%E4%B9%A6/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios%E8%A7%A3%E6%9E%90txt%E7%94%B5%E5%AD%90%E4%B9%A6/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;p&gt;昨天上线新版本因为Other-Other账号审核被拒了，估计要等待几天了，正好抽时间把最近写的东西整理一下。&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;附上APP地址： &lt;a href="https://apps.apple.com/cn/app/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/id1573880428" target="_blank" rel="external nofollow noopener noreferrer"&gt;一阅阅读&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;有想看小说的小伙伴可以试下 支持换源 支持自定义书源&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>iOS利用多线程进行网络请求</title><link>https://apolla.cc/posts/reading/ios%E5%88%A9%E7%94%A8%E5%A4%9A%E7%BA%BF%E7%A8%8B%E8%BF%9B%E8%A1%8C%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/ios%E5%88%A9%E7%94%A8%E5%A4%9A%E7%BA%BF%E7%A8%8B%E8%BF%9B%E8%A1%8C%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;h2 class="heading-element" id="1前言"&gt;&lt;span&gt;1.前言&lt;/span&gt;&#10; &lt;a href="#1%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;这两天忙着对付Other-Other的问题，今天才抽空给APP新增了一个离线缓存的功能，由于我的APP是对书源进行转码格式化阅读，所以缓存这里是个很头疼的问题，稍不慎就会503.目前的方案就是动态切换UA和利用多线程 一章一章下 收到失败就等待一会再继续，目前测试没什么问题。&lt;/p&gt;</description></item><item><title>Runloop实际使用</title><link>https://apolla.cc/posts/tips/runloop%E5%AE%9E%E9%99%85%E4%BD%BF%E7%94%A8/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/tips/runloop%E5%AE%9E%E9%99%85%E4%BD%BF%E7%94%A8/</guid><category domain="https://apolla.cc/categories/%E7%A2%8E%E7%89%87%E8%8A%9D%E5%A3%AB%E6%94%B6%E8%97%8F/">碎片芝士收藏</category><description>&lt;h2 class="heading-element" id="前言"&gt;&lt;span&gt;前言&lt;/span&gt;&#10; &lt;a href="#%e5%89%8d%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;p&gt;Runloop在iOS中是一个很重要的组成部分，对于任何单线程的UI模型都必须使用EvenLoop才可以连续处理不同的事件，而RunLoop就是EvenLoop模型在iOS中的实现。在前面的几篇文章中，我已经介绍了Runloop的底层原理等，这篇文章主要是从实际开发的角度，探讨一下实际上在哪些场景下，我们可以去使用RunLoop&lt;/p&gt;</description></item><item><title>SDL OpenAL</title><link>https://apolla.cc/posts/media/sdl-openal/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/media/sdl-openal/</guid><category domain="https://apolla.cc/categories/%E9%9F%B3%E8%A7%86%E9%A2%91/">音视频</category><description>&lt;h1 class="heading-element" id="1引言"&gt;&lt;span&gt;1.引言&lt;/span&gt;&#10; &lt;a href="#1%e5%bc%95%e8%a8%80" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;SDL (Simple DirectMedia Layer) 是一个跨平台的开源多媒体库，它提供了访问音频、键盘、鼠标、操纵杆以及图形硬件的底层接口。SDL 可用于开发游戏、仿真器、媒体播放器等多种类型的应用程序。&#10;1.1 SDL 的背景与应用领域&#10;SDL 由 Sam Lantinga 开发，最早发布于 1998 年。SDL 的设计目标是提供一个简单、轻量级且高效的多媒体库，使得开发者能够轻松地创建跨平台的应用程序。SDL 支持多种操作系统，包括 Windows、macOS、Linux、iOS 和 Android。&#10;SDL 的应用领域广泛，它常被用于以下场景：&lt;/p&gt;</description></item><item><title>面试 1 基础篇</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-1-%E5%9F%BA%E7%A1%80%E7%AF%87/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-1-%E5%9F%BA%E7%A1%80%E7%AF%87/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;h2 class="heading-element" id="父类实现深拷贝时子类如何实现深度拷贝父类没有实现深拷贝时子类如何实现深度拷贝"&gt;&lt;span&gt;父类实现深拷贝时，子类如何实现深度拷贝。父类没有实现深拷贝时，子类如何实现深度拷贝。&lt;/span&gt;&#10; &lt;a href="#%e7%88%b6%e7%b1%bb%e5%ae%9e%e7%8e%b0%e6%b7%b1%e6%8b%b7%e8%b4%9d%e6%97%b6%e5%ad%90%e7%b1%bb%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e6%b7%b1%e5%ba%a6%e6%8b%b7%e8%b4%9d%e7%88%b6%e7%b1%bb%e6%b2%a1%e6%9c%89%e5%ae%9e%e7%8e%b0%e6%b7%b1%e6%8b%b7%e8%b4%9d%e6%97%b6%e5%ad%90%e7%b1%bb%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e6%b7%b1%e5%ba%a6%e6%8b%b7%e8%b4%9d" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h2&gt;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;深拷贝同浅拷贝的区别：浅拷贝是指针拷贝，对一个对象进行浅拷贝，相当于对指向对象的指针进行复制，产生一个新的指向这个对象的指针，那么就是有两个指针指向同一个对象，这个对象销毁后两个指针都应该置空。深拷贝是对一个对象进行拷贝，相当于对对象进行复制，产生一个新的对象，那么就有两个指针分别 指向两个对象。当一个对象改变或者被销毁后拷贝出来的新的对象不受影响。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;实现深拷贝需要实现NSCoying协议，实现- (id)copyWithZone:(NSZone *)zone方法。当对一个property属性含有copy修饰符的时候，在进行赋值操作的时候实际上就是调用这个方法。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;父类实现深拷贝之后，子类只要重写copyWithZone方法，在方法内部调用父类的copyWithZone方法，之后实现自己的属性的处理&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;父类没有实现深拷贝，子类除了需要对自己的属性进行处理，还要对父类的属性进行处理。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>面试 10 专虐面试官</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-10-%E4%B8%93%E8%99%90%E9%9D%A2%E8%AF%95%E5%AE%98/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-10-%E4%B8%93%E8%99%90%E9%9D%A2%E8%AF%95%E5%AE%98/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (九) :专虐面试官&#10;2015年11月25日 星期三&#10;14:13&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="1你实现过一个框架或者库以供别人使用么如果有请谈一谈构建框架或者库时候的经验如果没有请设想和设计框架的public的api并指出大概需要如何做需要注意一些什么方面来使别人容易地使用你的框架"&gt;&lt;span&gt;1.你实现过一个框架或者库以供别人使用么？如果有，请谈一谈构建框架或者库时候的经验；如果没有，请设想和设计框架的public的API，并指出大概需要如何做、需要注意一些什么方面，来使别人容易地使用你的框架。&lt;/span&gt;&#10; &lt;a href="#1%e4%bd%a0%e5%ae%9e%e7%8e%b0%e8%bf%87%e4%b8%80%e4%b8%aa%e6%a1%86%e6%9e%b6%e6%88%96%e8%80%85%e5%ba%93%e4%bb%a5%e4%be%9b%e5%88%ab%e4%ba%ba%e4%bd%bf%e7%94%a8%e4%b9%88%e5%a6%82%e6%9e%9c%e6%9c%89%e8%af%b7%e8%b0%88%e4%b8%80%e8%b0%88%e6%9e%84%e5%bb%ba%e6%a1%86%e6%9e%b6%e6%88%96%e8%80%85%e5%ba%93%e6%97%b6%e5%80%99%e7%9a%84%e7%bb%8f%e9%aa%8c%e5%a6%82%e6%9e%9c%e6%b2%a1%e6%9c%89%e8%af%b7%e8%ae%be%e6%83%b3%e5%92%8c%e8%ae%be%e8%ae%a1%e6%a1%86%e6%9e%b6%e7%9a%84public%e7%9a%84api%e5%b9%b6%e6%8c%87%e5%87%ba%e5%a4%a7%e6%a6%82%e9%9c%80%e8%a6%81%e5%a6%82%e4%bd%95%e5%81%9a%e9%9c%80%e8%a6%81%e6%b3%a8%e6%84%8f%e4%b8%80%e4%ba%9b%e4%bb%80%e4%b9%88%e6%96%b9%e9%9d%a2%e6%9d%a5%e4%bd%bf%e5%88%ab%e4%ba%ba%e5%ae%b9%e6%98%93%e5%9c%b0%e4%bd%bf%e7%94%a8%e4%bd%a0%e7%9a%84%e6%a1%86%e6%9e%b6" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;抽象和封装，方便使用。首先是对问题有充分的了解，比如构建一个文件解压压缩框架，从使用者的角度出发，只需关注发送给框架一个解压请求，框架完成复杂文件的解压操作，并且在适当的时候通知给是哦难过者，如解压完成、解压出错等。在框架内部去构建对象的关系，通过抽象让其更为健壮、便于更改。其次是API的说明文档.&#10;1.提供给外界的接口功能是否实用、够用&#10;2.别人使用我的框架时，能不能根据类名、方法名就猜出接口的具体作用&#10;3.别人调用接口时，提供的参数是否够用、调用起来是否简单&#10;4.别人使用我的框架时，要不要再导入依赖其他的框架&lt;/p&gt;</description></item><item><title>面试 2 基础篇_1</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-2-%E5%9F%BA%E7%A1%80%E7%AF%87_1/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-2-%E5%9F%BA%E7%A1%80%E7%AF%87_1/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (二) :基础篇/1&#10;2015年11月25日 星期三&#10;10:05&#10;category和extension的区别&#10;• category：分类有名字，类扩展没i有分类名字，是一种特殊的分类&#10;• extension：分类只能扩展方法（属性仅仅是声明，并没真正实现），类扩展可以扩展属性、成员变量和方法&lt;/p&gt;</description></item><item><title>面试 3 基础篇_2</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-3-%E5%9F%BA%E7%A1%80%E7%AF%87_2/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-3-%E5%9F%BA%E7%A1%80%E7%AF%87_2/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (三) :基础篇/2&#10;2015年12月20日 星期日&#10;11:43&#10;1.Object-c的类可以多重继承么?可以实现多个接口么?Category是什么?重写一个类的方式用继承好还是分类好?为什么?&#10;答：Object-c的类不可以多重继承;可以实现多个接口，通过实现多个接口可以完成C++的多重继承;Category是类别，一般情况用分类好，用Category去重写类的方法，仅对本Category有效，不会影响到其他类与原有类的关系。&lt;/p&gt;</description></item><item><title>面试 4 原理篇</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-4-%E5%8E%9F%E7%90%86%E7%AF%87/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-4-%E5%8E%9F%E7%90%86%E7%AF%87/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (五) :原理篇&#10;2015年11月25日 星期三&#10;10:08&#10;runtime怎么添加属性、方法等&#10;• ivar表示成员变量&#10;• class_addIvar&#10;• class_addMethod&#10;• class_addProperty&#10;• class_addProtocol&#10;• class_replaceProperty&lt;/p&gt;&#10;&lt;p&gt;是否可以把比较耗时的操作放在NSNotificationCenter中&#10;•首先必须明确通知在哪个线程中发出，那么处理接受到通知的方法也在这个线程中调用&#10;•如果在异步线程发的通知，那么可以执行比较耗时的操作；&#10;•如果在主线程发的通知，那么就不可以执行比较耗时的操作&lt;/p&gt;</description></item><item><title>面试 5 UI篇</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-5-ui%E7%AF%87/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-5-ui%E7%AF%87/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (四) : UI篇&#10;2015年11月25日 星期三&#10;10:06&lt;/p&gt;&#10;&lt;p&gt;Size Classes具体使用&#10;•对屏幕进行分类&#10;UIView和CALayer是什么关系?&#10;• UIView显示在屏幕上归功于CALayer，通过调用drawRect方法来渲染自身的内容，调节CALayer属性可以调整UIView的外观，UIView继承自UIResponder，比起CALayer可以响应用户事件，Xcode6之后可以方便的通过视图调试功能查看图层之间的关系&#10;• UIView是iOS系统中界面元素的基础，所有的界面元素都继承自它。它内部是由Core Animation来实现的，它真正的绘图部分，是由一个叫CALayer(Core Animation Layer)的类来管理。UIView本身，更像是一个CALayer的管理器，访问它的跟绘图和坐标有关的属性，如frame，bounds等，实际上内部都是访问它所在CALayer的相关属性&#10;• UIView有个layer属性，可以返回它的主CALayer实例，UIView有一个layerClass方法，返回主layer所使用的类，UIView的子类，可以通过重载这个方法，来让UIView使用不同的CALayer来显示，如：&lt;/p&gt;</description></item><item><title>面试 6 原理篇_2</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-6-%E5%8E%9F%E7%90%86%E7%AF%87_2/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-6-%E5%8E%9F%E7%90%86%E7%AF%87_2/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (六) :原理篇/2&#10;2015年11月25日 星期三&#10;10:09&#10;lldb（gdb）常用的调试命令？&#10;• po：打印对象，会调用对象description方法。是print-object的简写&#10;• expr：可以在调试时动态执行指定表达式，并将结果打印出来，很有用的命令&#10;• print：也是打印命令，需要指定类型&#10;• bt：打印调用堆栈，是thread backtrace的简写，加all可打印所有thread的堆栈&#10;• br l：是breakpoint list的简写&#10;BAD_ACCESS在什么情况下出现？&#10;•访问一个僵尸对象，访问僵尸对象的成员变量或者向其发消息&#10;•死循环&#10;如何调试BAD_ACCESS错误&#10;•设置全局断点快速定位问题代码所在行&#10;开启僵尸对象调试功能&lt;/p&gt;</description></item><item><title>面试 7 其他篇</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-7-%E5%85%B6%E4%BB%96%E7%AF%87/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-7-%E5%85%B6%E4%BB%96%E7%AF%87/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试 (七) :其他篇&#10;2015年11月25日 星期三&#10;11:16&#10;常用的设计模式&#10;•单例模式&#10;•组合模式&#10;•观察者模式&#10;•代理模式&#10;•享元模式&#10;•工厂方法模式&#10;•抽象工厂模式&lt;/p&gt;&#10;&lt;p&gt;#MVC的理解&#10;•数据管理者(M)、数据展示者(V)、数据加工者(C)&#10;• M应该做的事：&#10;○给ViewController提供数据&#10;○给ViewController存储数据提供接口&#10;○提供经过抽象的业务基本组件，供Controller调度&#10;• C应该做的事：&#10;○管理View Container的生命周期&#10;○负责生成所有的View实例，并放入View Container&#10;○监听来自View与业务有关的事件，通过与Model的合作，来完成对应事件的业务。&#10;• V应该做的事：&#10;○响应与业务无关的事件，并因此引发动画效果，点击反馈（如果合适的话，尽量还是放在View去做）等。&#10;○界面元素表达&#10;#MVC和MVVM的区别&#10;• MVVM是对胖模型进行的拆分，其本质是给控制器减负，将一些弱业务逻辑放到VM中处理&#10;• MVC是一切设计的基础，所有新的设计模式都是基于MVC进行的改进&#10;•补充：常见的设计模式有：MVC、MVCS、MVVM、viper&#10;#TCP和UDP有什么区别？&#10;• TCP是面向连接的，建立连接需要经历三次握手，保证数据正确性和数据顺序&#10;• UDP是非连接的协议，传送数据受生成速度，传输带宽等限制，可能造成丢包&#10;• UDP一台服务端可以同时向多个客户端传输信息&#10;• TCP报头体积更大，对系统资源要求更多&#10;#TCP的三次握手&#10;•第一次握手：客户端发送syn包到服务器，并进入syn_send状态，等待服务器进行确认；&#10;•第二次握手：服务器收到客户端的syn包，必须确认客户的SYN，同时自己也发送一个SYN包,即SYN + ACK包，此时服务器进入SYN_RECV状态;&#10;•第三次握手：客户收到服务器发送的SYN+ACK包之后，向服务器发送确认包,此包发送完毕，客户端和服务器进入ESTABLISHED状态，完成第三次握手。&#10;#如何制作一个静态库/动态库？他们的区别是什么？&#10;• Xcode6支持制作静态库/动态库framework&#10;•无论是动态库还是静态库都是区分真机和模拟器的&#10;•静态库编译静态库文件装入程序空间，动态库是文件动态装入内存&#10;•动态库执行到相关函数才会被调用，节省空间&#10;•苹果一般不允许第三方动态库，APP容易被拒&#10;-一个lib包含了很多的架构，会打到最后的包里么？&#10;•不会，如果lib中有armv7, armv7s, arm64, i386,x86_64架构，而target architecture选择了armv7s,arm64，那么只会从lib中link指定的这两个架构的二进制代码，其他架构下的代码不会link到最终可执行文件中；反过来，一个lib需要在模拟器环境中正常link，也得包含i386架构的指令&lt;/p&gt;</description></item><item><title>面试 8 经典面试题</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-8-%E7%BB%8F%E5%85%B8%E9%9D%A2%E8%AF%95%E9%A2%98/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-8-%E7%BB%8F%E5%85%B8%E9%9D%A2%E8%AF%95%E9%A2%98/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;h3 class="heading-element" id="1你使用过objective-c的运行时编程runtime-programming么如果使用过你用它做了什么你还能记得你所使用的相关的头文件或者某些方法的名称吗"&gt;&lt;span&gt;1.你使用过Objective-C的运行时编程（Runtime Programming）么？如果使用过，你用它做了什么？你还能记得你所使用的相关的头文件或者某些方法的名称吗？&lt;/span&gt;&#10; &lt;a href="#1%e4%bd%a0%e4%bd%bf%e7%94%a8%e8%bf%87objective-c%e7%9a%84%e8%bf%90%e8%a1%8c%e6%97%b6%e7%bc%96%e7%a8%8bruntime-programming%e4%b9%88%e5%a6%82%e6%9e%9c%e4%bd%bf%e7%94%a8%e8%bf%87%e4%bd%a0%e7%94%a8%e5%ae%83%e5%81%9a%e4%ba%86%e4%bb%80%e4%b9%88%e4%bd%a0%e8%bf%98%e8%83%bd%e8%ae%b0%e5%be%97%e4%bd%a0%e6%89%80%e4%bd%bf%e7%94%a8%e7%9a%84%e7%9b%b8%e5%85%b3%e7%9a%84%e5%a4%b4%e6%96%87%e4%bb%b6%e6%88%96%e8%80%85%e6%9f%90%e4%ba%9b%e6%96%b9%e6%b3%95%e7%9a%84%e5%90%8d%e7%a7%b0%e5%90%97" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;Objecitve-C的重要特性是Runtime（运行时）,在#import &amp;lt;objc/runtime.h&amp;gt;下能看到相关的方法，用过objc_getClass()和class_copyMethodList()获取过私有API;使用&#10;Method method1 = class_getInstanceMethod(cls, sel1);&#10;Method method2 = class_getInstanceMethod(cls, sel2);&#10;method_exchangeImplementations(method1, method2);&#10;代码交换两个方法，在写unit test时使用到。&lt;/p&gt;&#10;&lt;h3 class="heading-element" id="2你实现过多线程的core-data么nspersistentstorecoordinatornsmanagedobjectcontext和nsmanagedobject中的哪些需要在线程中创建或者传递你是用什么样的策略来实现的"&gt;&lt;span&gt;2.你实现过多线程的Core Data么？NSPersistentStoreCoordinator，NSManagedObjectContext和NSManagedObject中的哪些需要在线程中创建或者传递？你是用什么样的策略来实现的？&lt;/span&gt;&#10; &lt;a href="#2%e4%bd%a0%e5%ae%9e%e7%8e%b0%e8%bf%87%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%9a%84core-data%e4%b9%88nspersistentstorecoordinatornsmanagedobjectcontext%e5%92%8cnsmanagedobject%e4%b8%ad%e7%9a%84%e5%93%aa%e4%ba%9b%e9%9c%80%e8%a6%81%e5%9c%a8%e7%ba%bf%e7%a8%8b%e4%b8%ad%e5%88%9b%e5%bb%ba%e6%88%96%e8%80%85%e4%bc%a0%e9%80%92%e4%bd%a0%e6%98%af%e7%94%a8%e4%bb%80%e4%b9%88%e6%a0%b7%e7%9a%84%e7%ad%96%e7%95%a5%e6%9d%a5%e5%ae%9e%e7%8e%b0%e7%9a%84" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h3&gt;&lt;p&gt;没实现过多线程的CoreData(待实践)&lt;/p&gt;</description></item><item><title>面试 9 高级面试题</title><link>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-9-%E9%AB%98%E7%BA%A7%E9%9D%A2%E8%AF%95%E9%A2%98/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/interview/%E9%9D%A2%E8%AF%95-9-%E9%AB%98%E7%BA%A7%E9%9D%A2%E8%AF%95%E9%A2%98/</guid><category domain="https://apolla.cc/categories/%E8%91%B5%E8%8A%B1%E5%AE%9D%E5%85%B8/">葵花宝典</category><description>&lt;p&gt;面试   (八) : 高级面试题&#10;2015年11月25日 星期三&#10;11:19&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;答的不对的地方,还请不吝指出 (陆续写答案) !&lt;/li&gt;&#10;&lt;li&gt;1.如何应对APP版本升级，数据结构随之变化?&lt;/li&gt;&#10;&lt;li&gt;如果是移动端, 视数据的重要性来定, 如果不重要, 那就忽视它. 如果重要, 就要额外做一个检查Documents(我这里假设你的数据文件放在Documents下)下的数据文件, 如果存在, 就SQL导出再加上按照新的数据结构导入到新的数据文件. 也就是两句SQL的事, 在升级后第一次进入应用的时候做这个事.&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;如果是服务端, 正常情况还是需要做接口层(当然, 我也遇到没做接口层, 直接远程数据库操作的, 对这种, 我无话可说), 接口层的变动幅度, 往往没有数据层的变动大, 有时候, 哪怕数据结构变化了, 但接口层还是一样. 如果是碰到数据层变化逼迫接口层变化的情况, 那就需要保留老接口的同时, 提供新接口服务, 直到使用老接口的app保有量低到一定程度, 再关闭老接口. 我的产品接口, 是在接口中加上一个v(version)参数作为版本判断标志.&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;2.常用的设计模式&lt;/li&gt;&#10;&lt;li&gt;（一）代理模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：当一个类的某些功能需要由别的类来实现，但是又不确定具体会是哪个类实现。&lt;/li&gt;&#10;&lt;li&gt;优势：解耦合&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：开放-封闭原则&lt;/li&gt;&#10;&lt;li&gt;实例：tableview的 数据源delegate，通过和protocol的配合，完成委托诉求。&lt;/li&gt;&#10;&lt;li&gt;列表row个数delegate&lt;/li&gt;&#10;&lt;li&gt;自定义的delegate&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;（二）观察者模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：一般为model层对，controller和view进行的通知方式，不关心谁去接收，只负责发布信息。&lt;/li&gt;&#10;&lt;li&gt;优势：解耦合&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：接口隔离原则，开放-封闭原则&lt;/li&gt;&#10;&lt;li&gt;实例：Notification通知中心，注册通知中心，任何位置可以发送消息，注册观察者的对象可以接收。&lt;/li&gt;&#10;&lt;li&gt;kvo，键值对改变通知的观察者，平时基本没用过。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;（三）MVC模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：是一中非常古老的设计模式，通过数据模型，控制器逻辑，视图展示将应用程序进行逻辑划分。&lt;/li&gt;&#10;&lt;li&gt;优势：使系统，层次清晰，职责分明，易于维护&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：对扩展开放-对修改封闭&lt;/li&gt;&#10;&lt;li&gt;实例：model-即数据模型，view-视图展示，controller进行UI展现和数据交互的逻辑控制。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;（四）单例模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：确保程序运行期某个类，只有一份实例，用于进行资源共享控制。&lt;/li&gt;&#10;&lt;li&gt;优势：使用简单，延时求值，易于跨模块&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：单一职责原则&lt;/li&gt;&#10;&lt;li&gt;实例：[UIApplication sharedApplication]。&lt;/li&gt;&#10;&lt;li&gt;注意事项：确保使用者只能通过 getInstance方法才能获得，单例类的唯一实例。&lt;/li&gt;&#10;&lt;li&gt;java，C++中使其没有公有构造函数，私有化并覆盖其构造函数。&lt;/li&gt;&#10;&lt;li&gt;object c中，重写allocWithZone方法，保证即使用户用 alloc方法直接创建单例类的实例，&lt;/li&gt;&#10;&lt;li&gt;返回的也只是此单例类的唯一静态变量。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;（五）策略模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：定义算法族，封装起来，使他们之间可以相互替换。&lt;/li&gt;&#10;&lt;li&gt;优势：使算法的变化独立于使用算法的用户&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：接口隔离原则；多用组合，少用继承；针对接口编程，而非实现。&lt;/li&gt;&#10;&lt;li&gt;实例：排序算法，NSArray的sortedArrayUsingSelector；经典的鸭子会叫，会飞案例。&lt;/li&gt;&#10;&lt;li&gt;注意事项：1，剥离类中易于变化的行为，通过组合的方式嵌入抽象基类&lt;/li&gt;&#10;&lt;li&gt;2，变化的行为抽象基类为，所有可变变化的父类&lt;/li&gt;&#10;&lt;li&gt;3，用户类的最终实例，通过注入行为实例的方式，设定易变行为&lt;/li&gt;&#10;&lt;li&gt;防止了继承行为方式，导致无关行为污染子类。完成了策略封装和可替换性。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;（六）工厂模式&lt;/li&gt;&#10;&lt;li&gt;应用场景：工厂方式创建类的实例，多与proxy模式配合，创建可替换代理类。&lt;/li&gt;&#10;&lt;li&gt;优势：易于替换，面向抽象编程，application只与抽象工厂和易变类的共性抽象类发生调用关系。&lt;/li&gt;&#10;&lt;li&gt;敏捷原则：DIP依赖倒置原则&lt;/li&gt;&#10;&lt;li&gt;实例：项目部署环境中依赖多个不同类型的数据库时，需要使用工厂配合proxy完成易用性替换&lt;/li&gt;&#10;&lt;li&gt;注意事项：项目初期，软件结构和需求都没有稳定下来时，不建议使用此模式，因为其劣势也很明显，&lt;/li&gt;&#10;&lt;li&gt;增 加了代码的复杂度，增加了调用层次，增加了内存负担。所以要注意防止模式的滥用。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;3.单例会有什么弊端？&lt;/li&gt;&#10;&lt;li&gt;主要优点：&lt;/li&gt;&#10;&lt;li&gt;1、提供了对唯一实例的受控访问。&lt;/li&gt;&#10;&lt;li&gt;2、由于在系统内存中只存在一个对象，因此可以节约系统资源，对于一些需要频繁创建和销毁的对象单例模式无疑可以提高系统的性能。&lt;/li&gt;&#10;&lt;li&gt;3、允许可变数目的实例。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;主要缺点：&lt;/li&gt;&#10;&lt;li&gt;1、由于单利模式中没有抽象层，因此单例类的扩展有很大的困难。&lt;/li&gt;&#10;&lt;li&gt;2、单例类的职责过重，在一定程度上违背了“单一职责原则”。&lt;/li&gt;&#10;&lt;li&gt;3、滥用单例将带来一些负面问题，如为了节省资源将数据库连接池对象设计为的单例类，可能会导致共享连接池对象的程序过多而出现连接池溢出；如果实例化的对象长时间不被利用，系统会认为是垃圾而被回收，这将导致对象状态的丢失。&lt;/li&gt;&#10;&lt;li&gt;  &lt;/li&gt;&#10;&lt;li&gt;4.编程题：简述「Snakes and Ladders」的实现思路&lt;/li&gt;&#10;&lt;li&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;⚠️ 原文图片缺失：%E9%9D%A2%E8%AF%95%20(%E5%85%AB)%20%3A%20%E9%AB%98%E7%BA%A7%E9%9D%A2%E8%AF%95%E9%A2%98.resources/E614ECD0-EED8-493E-8078-A68503581CD8.png#height=1383&amp;amp;width=476&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>模块化与解耦（网络摘要）</title><link>https://apolla.cc/posts/modularization/%E6%A8%A1%E5%9D%97%E5%8C%96%E4%B8%8E%E8%A7%A3%E8%80%A6%E7%BD%91%E7%BB%9C%E6%91%98%E8%A6%81/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/modularization/%E6%A8%A1%E5%9D%97%E5%8C%96%E4%B8%8E%E8%A7%A3%E8%80%A6%E7%BD%91%E7%BB%9C%E6%91%98%E8%A6%81/</guid><category domain="https://apolla.cc/categories/%E7%BB%84%E4%BB%B6%E5%8C%96/">组件化</category><description>&lt;h1 class="heading-element" id="简述"&gt;&lt;span&gt;简述&lt;/span&gt;&#10; &lt;a href="#%e7%ae%80%e8%bf%b0" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;本文主要讲述了在iOS开发过程中，模块化工程架构的一种组织方式，本文主要讲述基于cocoapods来做模块化的方案，详细讲述了iOS开发怎么进行模块划分的内容，主要会在以下方面做阐述：&lt;/p&gt;</description></item><item><title>隐私政策</title><link>https://apolla.cc/posts/reading/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96/</link><pubDate>Sat, 09 Mar 2024 23:21:58 +0800</pubDate><guid>https://apolla.cc/posts/reading/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96/</guid><category domain="https://apolla.cc/categories/%E4%B8%80%E9%98%85%E9%98%85%E8%AF%BB/">一阅阅读</category><description>&lt;p&gt;本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务，本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外，在未征得您事先许可的情况下，本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 您在同意本应用服务使用协议之时，即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。&lt;/p&gt;</description></item></channel></rss>