{"id":322574,"date":"2021-05-04T21:00:24","date_gmt":"2021-05-04T21:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322574"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322574","title":{"rendered":"10 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 Swift, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430 Livefront"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/wnfc\/\"><strong>&#171;iOS Developer. Basic&#187;.<\/strong><\/a><\/p>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0434\u0432\u0443\u0445\u0434\u043d\u0435\u0432\u043d\u044b\u0439 <strong>\u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432 \u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0435\u0434\u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430\u00bb.<\/strong> \u0412 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u0443\u0437\u043d\u0430\u0435\u043c:<\/p>\n<p>1. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 XCode?<br \/>2. \u041a\u0430\u043a &#171;\u0440\u0438\u0441\u0443\u044e\u0442\u0441\u044f \u044d\u043a\u0440\u0430\u043d\u044b&#187;<br \/>3. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u044b \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u043a\u0440\u0430\u043d \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>4. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043d\u0435\u0433\u043e \u0438\u0437 \u043e\u043a\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. <br \/>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e<a href=\"https:\/\/otus.pw\/vsgR\/\"><strong> \u0437\u0434\u0435\u0441\u044c.<\/strong><\/a><\/p>\n<\/blockquote>\n<hr>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 Swift \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0438\u0437\u044e\u043c\u0438\u043d\u043a\u0443<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0441\u0442\u043d\u044b\u043c\u0438. \u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 Swift \u0438 Apple \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u0432\u0441\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 Apple. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, Swift \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 Swift, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/docs.swift.org\/swift-book\/LanguageGuide\/Extensions.html\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0445 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0443\u0441\u044c \u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0442\u0438\u043f\u0430\u043c. \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u044f \u0431\u044b \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.&nbsp;<\/p>\n<p>\u0421\u0442\u0440\u0435\u043c\u044f\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043d\u0438\u0436\u0435 \u0431\u044b\u043b\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0440\u0430\u0442\u043a\u0438\u043c, \u044f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0438 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/atticus183\/TenExtensions\"><u>Xcode Playground<\/u><\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 GitHub.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 10 \u0438\u0437 \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 Livefront.<\/p>\n<h3>1. UIView \u2014 \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h3>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043a UIView<\/h4>\n<pre><code class=\"swift\">import PlaygroundSupport import UIKit  \/\/ Extension #1 - A helper method to add a view to another with top, left, bottom, and right constraints. extension UIView {      \/\/\/ Add a subview, constrained to the specified top, left, bottom and right margins.     \/\/\/     \/\/\/ - Parameters:     \/\/\/   - view: The subview to add.     \/\/\/   - top: Optional top margin constant.     \/\/\/   - left: Optional left (leading) margin constant.     \/\/\/   - bottom: Optional bottom margin constant.     \/\/\/   - right: Optional right (trailing) margin constant.     \/\/\/     func addConstrained(subview: UIView,                         top: CGFloat? = 0,                         left: CGFloat? = 0,                         bottom: CGFloat? = 0,                         right: CGFloat? = 0) {         subview.translatesAutoresizingMaskIntoConstraints = false         addSubview(subview)          if let top = top {             subview.topAnchor.constraint(equalTo: topAnchor, constant: top).isActive = true         }         if let left = left {             subview.leadingAnchor.constraint(equalTo: leadingAnchor, constant: left).isActive = true         }         if let bottom = bottom {             subview.bottomAnchor.constraint(equalTo: bottomAnchor, constant: bottom).isActive = true         }         if let right = right {             subview.trailingAnchor.constraint(equalTo: trailingAnchor, constant: right).isActive = true         }     } }  \/\/ Implementation class ViewController: UIViewController {      let newView = UIView()      override func viewDidLoad() {         super.viewDidLoad()         view.backgroundColor = .systemBlue          newView.backgroundColor = .systemTeal         view.addConstrained(subview: newView, top: 50, left: 100, right: -100)     }      }  let viewController = ViewController() PlaygroundPage.current.liveView = viewController<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c <code>translatesAutoresizingMaskIntoConstraints<\/code> \u0432 <code>false<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u044d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0437\u0430 \u0432\u0430\u0441. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0440\u0445\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0435, \u0437\u0430\u0434\u043d\u0438\u0435 \u0438 \u043d\u0438\u0436\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a \u043a\u0440\u0430\u044e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439.<\/p>\n<h3>2. \u0414\u0430\u0442\u0430 &#8212; \u0414\u0430\u0442\u0430 \u043f\u043e \u0432\u0441\u0435\u043c\u0438\u0440\u043d\u043e\u043c\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (UTC Date)<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Date \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u043c \u043f\u043e\u044f\u0441\u0435 UTC<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #2 - Create a date object from a date string with the UTC timezone. \/\/Inspired by: https:\/\/developer.apple.com\/library\/archive\/qa\/qa1480\/_index.html extension Date {     \/\/\/ Returns a date from the provided string.     \/\/\/     \/\/\/ - Parameter utcString: The string used to create the date.     \/\/\/     \/\/\/ - Returns: A date from the provided string.     \/\/\/     static func utcDate(from utcString: String) -&gt; Date? {         let formatter = DateFormatter()         formatter.dateFormat = \"yyyy-MM-dd'T'HH:mm:ss.SSSZ\"         formatter.locale = Locale(identifier: \"en_US_POSIX\")         formatter.timeZone = TimeZone(abbreviation: \"UTC\")!         return formatter.date(from: utcString)     } }  \/\/ Implementation let utcDateString = \"2021-04-03T14:00:00.000Z\" let utcDate = Date.utcDate(from: utcDateString) \/\/Playgrounds will show this in the machine's timezone. print(utcDate!)<\/code><\/pre>\n<p>API REST \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u0442\u044b \u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u043c \u043f\u043e\u044f\u0441\u0435 UTC. \u0412\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Date<\/code>. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e <code>dateFormat<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u0430\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435.<\/p>\n<h3>3. String (\u0421\u0442\u0440\u043e\u043a\u0430) \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u043e\u0432<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #3 - Retrieves valid URLs from a given string. \/\/Credit - Thanks to Paul Hudson for the core functionality on this extension. \/\/Source - https:\/\/www.hackingwithswift.com\/example-code\/strings\/how-to-detect-a-url-in-a-string-using-nsdatadetector extension String {     \/\/\/ Searches through a string to find valid URLs.     \/\/\/ - Returns: An array of found URLs.     func getURLs() -&gt; [URL] {         var foundUrls = [URL]()         guard let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else {             return foundUrls         }          let matches = detector.matches(             in: self,             options: [],             range: NSRange(location: 0, length: self.utf16.count)         )          for match in matches {             guard let range = Range(match.range, in: self),                   let retrievedURL = URL(string: String(self[range])) else { continue }             foundUrls.append(retrievedURL)         }          return foundUrls     } }  \/\/ Implementation let unfilteredString = \"To get the best search results, go to https:\/\/www.google.com, www.duckduckgo.com, or www.bing.com\" let urls = unfilteredString.getURLs()<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e URL \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u042f \u0431\u044b \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e JSON-\u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<h3>4. UIStackView \u2014 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/h3>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 subviews \u0438\u0437 UIStackView<\/h4>\n<pre><code class=\"swift\">import UIKit  \/\/ Extension #4 - Removes all views from a UIStackView. extension UIStackView {     \/\/\/ Removes all arranged subviews and their constraints from the view.     func removeAllArrangedSubviews() {         arrangedSubviews.forEach {             self.removeArrangedSubview($0)             NSLayoutConstraint.deactivate($0.constraints)             $0.removeFromSuperview()         }     } }  \/\/ Implementation let view1 = UIView() let view2 = UIView() let view3 = UIView()  let stackView = UIStackView()  \/\/Add subviews to stackView stackView.addArrangedSubview(view1) stackView.addArrangedSubview(view2) stackView.addArrangedSubview(view3)  \/\/Confirm stackView contains 3 views stackView.arrangedSubviews.count    \/\/3 \/\/Remove views from stackView stackView.removeAllArrangedSubviews()  \/\/Confirm stackView doesn't contain any subviews now stackView.arrangedSubviews.count    \/\/0<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 <code>UIStackView<\/code>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0445 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430, \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043b\u044e\u0431\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0448\u0430\u0433\u0430\u0445 \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<h3>5. Bundle \u2014 \u0412\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440 \u0441\u0431\u043e\u0440\u043a\u0438<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #5 - retrieve the app version # and build #. \/\/Inspired by https:\/\/stackoverflow.com\/questions\/25965239\/how-do-i-get-the-app-version-and-build-number-using-swift extension Bundle {     \/\/\/ Retrieve the app version # from Bundle     var releaseVersionNumber: String? {         return infoDictionary?[\"CFBundleShortVersionString\"] as? String     }      \/\/\/ Retrieve the build version # from Bundle     var buildVersionNumber: String? {         return infoDictionary?[\"CFBundleVersion\"] as? String     } }  \/\/ Implementation let releaseVersionNumber = Bundle.main.releaseVersionNumber let buildVersionNumber = Bundle.main.buildVersionNumber<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 <code>Bundle<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u044d\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0431\u043e\u0440\u043a\u0438. \u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u043c\u0435\u043d\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/p>\n<h3>6. \u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c \u2014 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0433\u043e\u0434<\/h3>\n<h4>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u043f\u043e \u0442\u0438\u043f\u0443 Integer<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #6 - Get the prior year as an integer extension Calendar {     \/\/\/ Returns the prior year as an integer.     \/\/\/     \/\/\/ - Returns: Returns last year's year as an integer.     func priorYear() -&gt; Int {         guard let priorYear = date(byAdding: .year, value: -1, to: Date()) else {             return component(.year, from: Date()) - 1         }         return component(.year, from: priorYear)     } }  \/\/Implementation let priorYearAsNumber = Calendar.current.priorYear()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e. \u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0433\u043e\u0434 \u0432 \u0432\u0438\u0434\u0435 Integer.<\/p>\n<h3>7. UIStackView \u2014 \u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e Init<\/h3>\n<h4>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e Init (\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f) \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/h4>\n<pre><code class=\"swift\">import PlaygroundSupport import UIKit  \/\/ Extension #7 - Make UIStackView creation a lot easier. extension UIStackView {      \/\/\/ `UIStackView` convenience initializer for creating a stack view with arranged subviews, an     \/\/\/ axis and spacing.     \/\/\/     \/\/\/ - Parameters:     \/\/\/   - alignment: The alignment of the arranged subviews perpendicular to the stack view\u2019s     \/\/\/                axis.     \/\/\/   - arrangedSubviews: The subviews to arrange in the `UIStackView`.     \/\/\/   - axis: The axis that the subviews should be arranged around.     \/\/\/   - distribution: The distribution of the arranged views along the stack view\u2019s axis.     \/\/\/   - spacing: The spacing to place between each arranged subview. Defaults to 0.     \/\/\/     convenience init(alignment: UIStackView.Alignment = .fill,                      arrangedSubviews: [UIView],                      axis: NSLayoutConstraint.Axis,                      distribution: UIStackView.Distribution = .fill,                      spacing: CGFloat = 0) {         arrangedSubviews.forEach { $0.translatesAutoresizingMaskIntoConstraints = false }         self.init(arrangedSubviews: arrangedSubviews)         self.alignment = alignment         self.axis = axis         self.distribution = distribution         self.spacing = spacing     } }  \/\/ Implementation let view1 = UIView() view1.backgroundColor = .systemPink let view2 = UIView() view2.backgroundColor = .systemOrange let view3 = UIView() view3.backgroundColor = .systemTeal  let stackView = UIStackView(alignment: .leading,                             arrangedSubviews: [view1, view2, view3],                             axis: .vertical,                             distribution: .fill,                             spacing: 20)    let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) view.backgroundColor = .systemBlue view.addSubview(stackView) stackView.translatesAutoresizingMaskIntoConstraints = false  NSLayoutConstraint.activate([     view1.heightAnchor.constraint(equalToConstant: 50),     view1.widthAnchor.constraint(equalToConstant: 150),     view2.heightAnchor.constraint(equalToConstant: 50),     view2.widthAnchor.constraint(equalToConstant: 150),     view3.heightAnchor.constraint(equalToConstant: 50),     view3.widthAnchor.constraint(equalToConstant: 150),     stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),     stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor), ])  PlaygroundPage.current.liveView = view<\/code><\/pre>\n<p>\u0417\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f <code>UIStackView<\/code>, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e. \u042d\u0442\u043e\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0432\u043e\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 <code>translatesAutoresizingMaskIntoConstraints<\/code> \u0432 <code>false<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h2>8. UIColor \u2014 Hex<\/h2>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 Hex (\u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0433\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f UIColor<\/h4>\n<pre><code class=\"swift\">import UIKit  \/\/ Extension #8 - generates a string with the hex color value. \/\/Inspired by: https:\/\/stackoverflow.com\/a\/26341062 extension UIColor {     \/\/ MARK: - Helper Functions     \/\/\/ Returns the hex string for this `UIColor`. For example: `#FFFFFF` or `#222222AB` if the alpha value is included.     \/\/\/     \/\/\/ - Parameter includeAlpha: A boolean indicating if the alpha value should be included in the returned hex string.     \/\/\/     \/\/\/ - Returns: The hex string for this `UIColor`. For example: `#FFFFFF` or     \/\/\/            `#222222AB` if the alpha value is included.     \/\/\/     func hexString(includeAlpha: Bool = false) -&gt; String {         let components = cgColor.components         let red: CGFloat = components?[0] ?? 0.0         let green: CGFloat = components?[1] ?? 0.0         let blue: CGFloat = components?[2] ?? 0.0         let alpha: CGFloat = components?[3] ?? 0.0         let hexString = String.init(             format: \"#%02lX%02lX%02lX%02lX\",             lroundf(Float(red * 255)),             lroundf(Float(green * 255)),             lroundf(Float(blue * 255)),             lroundf(Float(alpha * 255))         )         return includeAlpha ? hexString : String(hexString.dropLast(2))     } }  \/\/ Implementation let whiteColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1)  let whiteHexString = whiteColor.hexString() \/\/#FFFFFF let blackColor = UIColor(displayP3Red: 0, green: 0, blue: 0, alpha: 1)  let blackHexString = blackColor.hexString() \/\/#000000<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>UIColor<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u0432\u0438\u0434\u0435 <code>String<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0445 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 RGB.<\/p>\n<h3>9. UIViewController \u2014 \u0422\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c<\/h3>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0442\u0435\u043c\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c<\/h4>\n<pre><code class=\"swift\">import UIKit  \/\/ Extension #9 extension UIViewController {     \/\/\/ Gets a flag indicating whether or not the UI is in dark mode.     public var isDarkMode: Bool {         if #available(iOS 12.0, *) {             return traitCollection.userInterfaceStyle == .dark         }         return false     } }<\/code><\/pre>\n<p><code>UIColors<\/code>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>.label<\/code>, <code>.systemBlue<\/code> \u0438 \u0442.\u0434., \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u0435\u0442\u043b\u044b\u043c \u0438 \u0442\u0435\u043c\u043d\u044b\u043c \u0440\u0435\u0436\u0438\u043c\u043e\u043c, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u042d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0430\u043a\u0442\u0438\u0432\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0442\u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>10. UICollectionView \u2014 \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 IndexPath<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 indexPath \u0434\u043b\u044f collectionView<\/h4>\n<pre><code class=\"swift\">import PlaygroundSupport import UIKit  \/\/ Extension #10 - get the last valid indexPath in a UICollectionView. extension UICollectionView {      \/\/\/ Validates whether an `IndexPath` is a valid index path for an item in a collection view.     \/\/\/     \/\/\/ - Parameter indexPath: The index path to validate.     \/\/\/ - Returns: `true` if the index path represents an item in the collection view or false     \/\/\/     otherwise.     \/\/\/     func isValid(_ indexPath: IndexPath) -&gt; Bool {         guard indexPath.section &lt; numberOfSections,               indexPath.item &lt; numberOfItems(inSection: indexPath.section)         else {             return false         }          return true     }      \/\/\/ Provides the last valid `indexPath` in the collection view.     \/\/\/ - Parameter section: The section used to provide the last `indexPath`.     \/\/\/ - Returns: the last valid `indexPath` in the collection view or nil if not a valid `indexPath`.     func lastIndexPath(in section: Int) -&gt; IndexPath? {         let lastIndexPath = IndexPath(row: numberOfItems(inSection: section) - 1, section: section)         guard isValid(lastIndexPath) else { return nil }         return lastIndexPath     } }  \/\/ Implementation class CollectionViewController: UICollectionViewController {      let items = Array(1...100)      override func viewDidLoad() {         super.viewDidLoad()          collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: \"cell\")     }      override func numberOfSections(in collectionView: UICollectionView) -&gt; Int {         return 1     }      override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {         return items.count     }      override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: \"cell\", for: indexPath)         cell.backgroundColor = .systemBlue         return cell     } }  let collectionViewController = CollectionViewController(collectionViewLayout: UICollectionViewFlowLayout()) let lastIndexPath = collectionViewController.collectionView.lastIndexPath(in: 0) lastIndexPath?.section  \/\/0 lastIndexPath?.row      \/\/99 PlaygroundPage.current.liveView = collectionViewController<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432 <code>UICollectionView<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 <code>indexPath<\/code>. \u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 UIKit. \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e \u043f\u0443\u0442\u0435\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>collectionView<\/code> \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f; \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435.<\/p>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<p>\u042f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0435\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 Swift \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u043c \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u042f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0430\u043c \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 &#171;\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f Swift&#187; \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435 \u043e\u0442 \u0432\u0441\u0435\u0445 \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u043d\u0430\u0448\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0438-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<p>\u041d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043b\u044e\u0431\u0438\u043c\u044b\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c (\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438) \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043d\u0438\u0436\u0435. <\/p>\n<p><strong>\u0420\u0435\u0441\u0443\u0440\u0441\u044b:<\/strong><\/p>\n<p><a href=\"https:\/\/docs.swift.org\/swift-book\/LanguageGuide\/Protocols.html#ID521\"><u>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/u><\/a><\/p>\n<p><a href=\"https:\/\/docs.swift.org\/swift-book\/LanguageGuide\/Extensions.html\"><u>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f Swift<\/u><\/a><\/p>\n<p><a href=\"https:\/\/docs.swift.org\/swift-book\/LanguageGuide\/Generics.html#ID553\"><u>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439<\/u><\/a><\/p>\n<hr>\n<blockquote>\n<p>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u0443\u0440\u0441\u0435 <a href=\"https:\/\/otus.pw\/wnfc\/\"><strong>&#171;iOS Developer. Basic&#187;<\/strong><\/a><\/p>\n<p>\u0423\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u0435<strong> <\/strong><a href=\"https:\/\/otus.pw\/vsgR\/\"><strong>\u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0435\u0434\u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430\u00bb<\/strong><\/a><strong> <\/strong><\/p>\n<\/blockquote>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/555686\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/555686\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<blockquote>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/wnfc\/\"><strong>&#171;iOS Developer. Basic&#187;.<\/strong><\/a><\/p>\n<p>\u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0434\u0432\u0443\u0445\u0434\u043d\u0435\u0432\u043d\u044b\u0439 <strong>\u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432 \u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0435\u0434\u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430\u00bb.<\/strong> \u0412 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u0443\u0437\u043d\u0430\u0435\u043c:<\/p>\n<p>1. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 XCode?<br \/>2. \u041a\u0430\u043a &#171;\u0440\u0438\u0441\u0443\u044e\u0442\u0441\u044f \u044d\u043a\u0440\u0430\u043d\u044b&#187;<br \/>3. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u044b \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u043a\u0440\u0430\u043d \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>4. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043d\u0435\u0433\u043e \u0438\u0437 \u043e\u043a\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. <br \/>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e<a href=\"https:\/\/otus.pw\/vsgR\/\"><strong> \u0437\u0434\u0435\u0441\u044c.<\/strong><\/a><\/p>\n<\/blockquote>\n<hr>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 Swift \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0438\u0437\u044e\u043c\u0438\u043d\u043a\u0443<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0441\u0442\u043d\u044b\u043c\u0438. \u0424\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 Swift \u0438 Apple \u043d\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u0432\u0441\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 Apple. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, Swift \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 Swift, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/docs.swift.org\/swift-book\/LanguageGuide\/Extensions.html\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0445 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0443\u0441\u044c \u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0442\u0438\u043f\u0430\u043c. \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u044f \u0431\u044b \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.&nbsp;<\/p>\n<p>\u0421\u0442\u0440\u0435\u043c\u044f\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043d\u0438\u0436\u0435 \u0431\u044b\u043b\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0440\u0430\u0442\u043a\u0438\u043c, \u044f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0438 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/atticus183\/TenExtensions\"><u>Xcode Playground<\/u><\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 GitHub.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 10 \u0438\u0437 \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 Livefront.<\/p>\n<h3>1. UIView \u2014 \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h3>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043a UIView<\/h4>\n<pre><code class=\"swift\">import PlaygroundSupport import UIKit  \/\/ Extension #1 - A helper method to add a view to another with top, left, bottom, and right constraints. extension UIView {      \/\/\/ Add a subview, constrained to the specified top, left, bottom and right margins.     \/\/\/     \/\/\/ - Parameters:     \/\/\/   - view: The subview to add.     \/\/\/   - top: Optional top margin constant.     \/\/\/   - left: Optional left (leading) margin constant.     \/\/\/   - bottom: Optional bottom margin constant.     \/\/\/   - right: Optional right (trailing) margin constant.     \/\/\/     func addConstrained(subview: UIView,                         top: CGFloat? = 0,                         left: CGFloat? = 0,                         bottom: CGFloat? = 0,                         right: CGFloat? = 0) {         subview.translatesAutoresizingMaskIntoConstraints = false         addSubview(subview)          if let top = top {             subview.topAnchor.constraint(equalTo: topAnchor, constant: top).isActive = true         }         if let left = left {             subview.leadingAnchor.constraint(equalTo: leadingAnchor, constant: left).isActive = true         }         if let bottom = bottom {             subview.bottomAnchor.constraint(equalTo: bottomAnchor, constant: bottom).isActive = true         }         if let right = right {             subview.trailingAnchor.constraint(equalTo: trailingAnchor, constant: right).isActive = true         }     } }  \/\/ Implementation class ViewController: UIViewController {      let newView = UIView()      override func viewDidLoad() {         super.viewDidLoad()         view.backgroundColor = .systemBlue          newView.backgroundColor = .systemTeal         view.addConstrained(subview: newView, top: 50, left: 100, right: -100)     }      }  let viewController = ViewController() PlaygroundPage.current.liveView = viewController<\/code><\/pre>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c <code>translatesAutoresizingMaskIntoConstraints<\/code> \u0432 <code>false<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u044d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0437\u0430 \u0432\u0430\u0441. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0435\u0440\u0445\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u043d\u0438\u0435, \u0437\u0430\u0434\u043d\u0438\u0435 \u0438 \u043d\u0438\u0436\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a \u043a\u0440\u0430\u044e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439.<\/p>\n<h3>2. \u0414\u0430\u0442\u0430 &#8212; \u0414\u0430\u0442\u0430 \u043f\u043e \u0432\u0441\u0435\u043c\u0438\u0440\u043d\u043e\u043c\u0443 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (UTC Date)<\/h3>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Date \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u043c \u043f\u043e\u044f\u0441\u0435 UTC<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #2 - Create a date object from a date string with the UTC timezone. \/\/Inspired by: https:\/\/developer.apple.com\/library\/archive\/qa\/qa1480\/_index.html extension Date {     \/\/\/ Returns a date from the provided string.     \/\/\/     \/\/\/ - Parameter utcString: The string used to create the date.     \/\/\/     \/\/\/ - Returns: A date from the provided string.     \/\/\/     static func utcDate(from utcString: String) -&gt; Date? {         let formatter = DateFormatter()         formatter.dateFormat = \"yyyy-MM-dd'T'HH:mm:ss.SSSZ\"         formatter.locale = Locale(identifier: \"en_US_POSIX\")         formatter.timeZone = TimeZone(abbreviation: \"UTC\")!         return formatter.date(from: utcString)     } }  \/\/ Implementation let utcDateString = \"2021-04-03T14:00:00.000Z\" let utcDate = Date.utcDate(from: utcDateString) \/\/Playgrounds will show this in the machine's timezone. print(utcDate!)<\/code><\/pre>\n<p>API REST \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0430\u0442\u044b \u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u043c \u043f\u043e\u044f\u0441\u0435 UTC. \u0412\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Date<\/code>. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u044d\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0432 \u0432\u0430\u0448\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e <code>dateFormat<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u0430\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435.<\/p>\n<h3>3. String (\u0421\u0442\u0440\u043e\u043a\u0430) \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u043e\u0432<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #3 - Retrieves valid URLs from a given string. \/\/Credit - Thanks to Paul Hudson for the core functionality on this extension. \/\/Source - https:\/\/www.hackingwithswift.com\/example-code\/strings\/how-to-detect-a-url-in-a-string-using-nsdatadetector extension String {     \/\/\/ Searches through a string to find valid URLs.     \/\/\/ - Returns: An array of found URLs.     func getURLs() -&gt; [URL] {         var foundUrls = [URL]()         guard let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) else {             return foundUrls         }          let matches = detector.matches(             in: self,             options: [],             range: NSRange(location: 0, length: self.utf16.count)         )          for match in matches {             guard let range = Range(match.range, in: self),                   let retrievedURL = URL(string: String(self[range])) else { continue }             foundUrls.append(retrievedURL)         }          return foundUrls     } }  \/\/ Implementation let unfilteredString = \"To get the best search results, go to https:\/\/www.google.com, www.duckduckgo.com, or www.bing.com\" let urls = unfilteredString.getURLs()<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e URL \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u042f \u0431\u044b \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e JSON-\u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<h3>4. UIStackView \u2014 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439<\/h3>\n<h4>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 subviews \u0438\u0437 UIStackView<\/h4>\n<pre><code class=\"swift\">import UIKit  \/\/ Extension #4 - Removes all views from a UIStackView. extension UIStackView {     \/\/\/ Removes all arranged subviews and their constraints from the view.     func removeAllArrangedSubviews() {         arrangedSubviews.forEach {             self.removeArrangedSubview($0)             NSLayoutConstraint.deactivate($0.constraints)             $0.removeFromSuperview()         }     } }  \/\/ Implementation let view1 = UIView() let view2 = UIView() let view3 = UIView()  let stackView = UIStackView()  \/\/Add subviews to stackView stackView.addArrangedSubview(view1) stackView.addArrangedSubview(view2) stackView.addArrangedSubview(view3)  \/\/Confirm stackView contains 3 views stackView.arrangedSubviews.count    \/\/3 \/\/Remove views from stackView stackView.removeAllArrangedSubviews()  \/\/Confirm stackView doesn't contain any subviews now stackView.arrangedSubviews.count    \/\/0<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 <code>UIStackView<\/code>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0445 \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430, \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043b\u044e\u0431\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0445\u0435\u043b\u043f\u0435\u0440-\u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0448\u0430\u0433\u0430\u0445 \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<h3>5. Bundle \u2014 \u0412\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440 \u0441\u0431\u043e\u0440\u043a\u0438<\/h3>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440 \u0441\u0431\u043e\u0440\u043a\u0438<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #5 - retrieve the app version # and build #. \/\/Inspired by https:\/\/stackoverflow.com\/questions\/25965239\/how-do-i-get-the-app-version-and-build-number-using-swift extension Bundle {     \/\/\/ Retrieve the app version # from Bundle     var releaseVersionNumber: String? {         return infoDictionary?[\"CFBundleShortVersionString\"] as? String     }      \/\/\/ Retrieve the build version # from Bundle     var buildVersionNumber: String? {         return infoDictionary?[\"CFBundleVersion\"] as? String     } }  \/\/ Implementation let releaseVersionNumber = Bundle.main.releaseVersionNumber let buildVersionNumber = Bundle.main.buildVersionNumber<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0435\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 <code>Bundle<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u044d\u0442\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0431\u043e\u0440\u043a\u0438. \u041c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u043c\u0435\u043d\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a.<\/p>\n<h3>6. \u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c \u2014 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0433\u043e\u0434<\/h3>\n<h4>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u043f\u043e \u0442\u0438\u043f\u0443 Integer<\/h4>\n<pre><code class=\"swift\">import Foundation  \/\/ Extension #6 - Get the prior year as an integer extension Calendar {     \/\/\/ Returns the prior year as an integer.     \/\/\/     \/\/\/ - Returns: Returns last year's year as an integer.     func priorYear() -&gt; Int {         guard let priorYear = date(byAdding: .year, value: -1, to: Date()) else {             return component(.year, from: Date()) - 1         }         return component(.year, from: priorYear)     } }  \/\/Implementation let priorYearAsNumber = Calendar.current.priorYear()<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e. \u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0433\u043e\u0434 \u0432 \u0432\u0438\u0434\u0435 Integer.<\/p>\n<h3>7. UIStackView \u2014 \u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e Init<\/h3>\n<h4>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e Init (\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f) \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/h4>\n<pre><code class=\"swift\">import<\/code><\/pre>\n<\/hr>\n<p><\/br><\/br><\/p>\n<p><\/br><\/p>\n<\/blockquote>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322574","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322574"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322574\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}