{"id":10551,"date":"2020-09-21T00:00:00","date_gmt":"2020-09-21T00:00:00","guid":{"rendered":"https:\/\/dev95.site\/context-bound-types\/"},"modified":"2020-09-21T00:00:00","modified_gmt":"2020-09-21T00:00:00","slug":"context-bound-types","status":"publish","type":"post","link":"https:\/\/dev95.site\/ar\/context-bound-types\/","title":{"rendered":"Context-Bound Types"},"content":{"rendered":"<div id=\"dev95-4178218245\" class=\"dev95-- dev95-entity-placement\" role=\"region\" aria-label=\"\u0627\u0644\u0625\u0639\u0644\u0627\u0646\u0627\u062a\"><script async=\"async\" data-cfasync=\"false\" src=\"https:\/\/pl27862732.profitableratecpmnetwork.com\/2ad7a50e0bbc23ac6801d7b77c501463\/invoke.js\"><\/script>\r\n<div id=\"container-2ad7a50e0bbc23ac6801d7b77c501463\"><\/div><\/div><div id=\"dev95-229727536\" class=\"dev95-before-content dev95-entity-placement\" role=\"region\" aria-label=\"\u0627\u0644\u0625\u0639\u0644\u0627\u0646\u0627\u062a\"><p style=\"text-align: center;\"><strong>Stop wasting time on dead links! \ud83d\uded1 This smart platform automatically detects your device and country to give you the exact best offer instantly. Check it out now 100% free! \ud83d\udc47<\/strong><br data-sfc-root=\"ep\" data-sfc-pl=\"|||[]\" data-complete=\"true\" data-copy-service-computed-style=\"font-family: Arial, sans-serif, &quot;Noto Color Emoji&quot;; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);\" \/><a href=\"https:\/\/www.profitableratecpmnetwork.com\/pvhx5mbcc?key=ff7d362db3c20bc86fad685cc94f1fc4\">\ud83d\udd17 <strong class=\"rQesXe MPyX\" data-sfc-cp=\"\" data-sfc-root=\"ep\" data-complete=\"true\" aria-owns=\"action-menu-parent-container\" data-copy-service-computed-style=\"font-family: Arial, sans-serif, &quot;Noto Color Emoji&quot;; font-size: 16px; font-weight: 700; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);\">[Click here]<\/strong><\/a><\/p>\n<\/div><div>\n<p>I&#8217;ve been thinking about privacy lately. No, not <a href=\"https:\/\/www.fabisevi.ch\/2018\/01\/16\/the-future-will-be-signed\/\">online<\/a> <a href=\"https:\/\/www.fabisevi.ch\/2019\/01\/01\/pushing-the-boundaries-of-technology\/\">privacy<\/a>, but about how APIs can balance exposing the right amount of implementation details without revealing too much.<\/p><div id=\"dev95-180883742\" class=\"dev95- dev95-entity-placement\" role=\"region\" aria-label=\"\u0627\u0644\u0625\u0639\u0644\u0627\u0646\u0627\u062a\"><center>\r\n<script>\r\n  atOptions = {\r\n    'key' : '4ba6b6513c00e0ba76511f798ae56401',\r\n    'format' : 'iframe',\r\n    'height' : 50,\r\n    'width' : 320,\r\n    'params' : {}\r\n  };\r\n<\/script>\r\n<script src=\"https:\/\/www.highrevenueformat.com\/4ba6b6513c00e0ba76511f798ae56401\/invoke.js\"><\/script>\r\n\t<\/center><\/div>\n<p>I&#8217;ll walk through a task I find myself doing often when building iOS apps, creating a view controller with header view, and four different ways to go about it.<\/p>\n<p><!--preview-snippet--><\/p>\n<hr>\n<h3 id=\"regular-view-configured-as-a-header\" style=\"position:relative;\"><a href=\"https:\/\/fabisevi.ch\/2020\/09\/21\/Context-Bound-Types\/#regular-view-configured-as-a-header\" aria-label=\"regular view configured as a header permalink\" class=\"anchor before\"><svg class=\"header-link\" aria-hidden=\"true\" height=\"24\" version=\"1.1\" viewbox=\"0.5 -2 16 16\" width=\"24\"><path fill=\"currentColor\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Regular View Configured as a Header<\/h3>\n<p><em>SettingsViewController.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">final class SettingsViewController: UIViewController {\n    \n    private let headerView = UIView()\n    \n    private let tableView = UITableView()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n    \n        self.view.addSubview(self.tableView)\n        self.setupTableView()\n        self.configureHeaderView()\n    }\n    \n    func setupTableView() {\n        self.tableView.translatesAutoresizingMaskIntoConstraints = false\n        NSLayoutConstraint.activate([\n            self.tableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),\n            self.tableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),\n            self.tableView.topAnchor.constraint(equalTo: self.view.topAnchor),\n            self.tableView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),\n        ])\n    }\n    \n    func configureHeaderView() {\n        \/\/ Some code configuring self.headerView\n        \/\/ ...\n        \/\/ ...\n        self.tableView.tableHeaderView = self.headerView\n    }\n\n}<\/code><\/pre>\n<\/div>\n<p>For folks new to iOS development, this is a common approach I see when adding a header. It makes sense, you want to have a header, and a header is a view, so why not configure and style  <code class=\"language-text\">UIView<\/code> to be the  <code class=\"language-text\">UITableView<\/code> header. While this is a good first try, it lacks the encapsulation that makes your code easy to edit and reason about.<\/p>\n<hr>\n<h3 id=\"separate-class-for-the-header\" style=\"position:relative;\"><a href=\"https:\/\/fabisevi.ch\/2020\/09\/21\/Context-Bound-Types\/#separate-class-for-the-header\" aria-label=\"separate class for the header permalink\" class=\"anchor before\"><svg class=\"header-link\" aria-hidden=\"true\" height=\"24\" version=\"1.1\" viewbox=\"0.5 -2 16 16\" width=\"24\"><path fill=\"currentColor\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Separate Class For The Header<\/h3>\n<p><em>SettingsViewController.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">final class SettingsViewController: UIViewController {\n    \n    private let headerView = SettingsTableHeaderView()\n    \n    private let tableView = UITableView()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n    \n        self.view.addSubview(self.tableView)\n        self.setupTableView()\n    \n        self.tableView.tableHeaderView = self.headerView\n    }\n}<\/code><\/pre>\n<\/div>\n<p><em>SettingsTableHeaderView.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">final class SettingsTableHeaderView: UIView {\n    \/\/ Some code creating and configuring SettingsTableHeaderView\n    \/\/ ...\n    \/\/ ...\n}<\/code><\/pre>\n<\/div>\n<p>A naive approach to improve our readability would have been to move our configuration code into a function, but an even nicer improvement is to move it into its own class. This looks a lot better, it&#8217;s easier to reason about and it&#8217;s well-encapsulated. But a new problem this introduces is adding <code class=\"language-text\">SettingsTableHeaderView<\/code> into our module\u2019s namespace. Now I&#8217;ll admit this isn&#8217;t the world&#8217;s biggest problem, but as you start adding different view controllers with different headers, suddenly finding the right header view for a given view controller becomes difficult.<\/p>\n<hr>\n<h3 id=\"private-class-for-the-header\" style=\"position:relative;\"><a href=\"https:\/\/fabisevi.ch\/2020\/09\/21\/Context-Bound-Types\/#private-class-for-the-header\" aria-label=\"private class for the header permalink\" class=\"anchor before\"><svg class=\"header-link\" aria-hidden=\"true\" height=\"24\" version=\"1.1\" viewbox=\"0.5 -2 16 16\" width=\"24\"><path fill=\"currentColor\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Private Class for the Header<\/h3>\n<p><em>SettingsViewController.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">final class SettingsViewController: UIViewController {\n    \n    private let headerView = HeaderView()\n    \n    private let tableView = UITableView()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n    \n        self.view.addSubview(self.tableView)\n        self.setupTableView()\n    \n        self.tableView.tableHeaderView = self.headerView\n    }\n    \n    private final class HeaderView: UIView {\n      \/\/ Some code creating and configuring SettingsViewController.HeaderView\n      \/\/ ...\n      \/\/ ...\n    }\n    \n}<\/code><\/pre>\n<\/div>\n<p>Now this is a solution that I&#8217;m really liking. We&#8217;ve moved <code class=\"language-text\">SettingsTableHeaderView<\/code> out of our module\u2019s namespace and into one dependent on the context it&#8217;s in,  <code class=\"language-text\">SettingsViewController<\/code>. When referring to  <code class=\"language-text\">SettingsViewController.HeaderView<\/code> inside of this class we can plainly refer to it as <code class=\"language-text\">HeaderView<\/code>, which is not only less verbose, but emphasizes the pairing between  <code class=\"language-text\">HeaderView<\/code> and  <code class=\"language-text\">SettingsViewController<\/code>.<\/p>\n<p>There is a downside to this approach though, the more views we add to  <code class=\"language-text\">SettingsViewController<\/code>, the harder this file becomes to parse. Now again this may not seem like a big problem, but if you have a well encapsulated view, you may have many subviews that belong to either <code class=\"language-text\">SettingsViewController<\/code> or <code class=\"language-text\">HeaderView<\/code>, and your file can get pretty large. (Trust me, I\u2019ve <del>seen<\/del> written some pretty large files.)<\/p>\n<hr>\n<h3 id=\"two-files-with-namespaced-internal-classes\" style=\"position:relative;\"><a href=\"https:\/\/fabisevi.ch\/2020\/09\/21\/Context-Bound-Types\/#two-files-with-namespaced-internal-classes\" aria-label=\"two files with namespaced internal classes permalink\" class=\"anchor before\"><svg class=\"header-link\" aria-hidden=\"true\" height=\"24\" version=\"1.1\" viewbox=\"0.5 -2 16 16\" width=\"24\"><path fill=\"currentColor\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Two Files with Namespaced Internal Classes<\/h3>\n<p><em>SettingsViewController.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">final class SettingsViewController: UIViewController {\n    \n    private let headerView = HeaderView()\n    \n    private let tableView = UITableView()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n    \n        self.view.addSubview(self.tableView)\n        self.setupTableView()\n    \n        self.tableView.tableHeaderView = self.headerView\n    }\n\n}<\/code><\/pre>\n<\/div>\n<p><em>SettingsViewController.HeaderView.swift<\/em><\/p>\n<div class=\"gatsby-highlight\" data-language=\"text\">\n<pre class=\"language-text\"><code class=\"language-text\">extension SettingsViewController {\n    \n    final class HeaderView: UIView {\n      \/\/ Some code creating and configuring SettingsViewController.HeaderView\n      \/\/ ...\n      \/\/ ... \n    }\n    \n}<\/code><\/pre>\n<\/div>\n<p>This is the approach I&#8217;ve settled on today. You&#8217;ll notice that  <code class=\"language-text\">HeaderView<\/code> is no longer private, but it&#8217;s also not particularly easy to access publicly. You still end up with the benefits from namespacing the API, and this extension can go into its own file, unlike the earlier approach.<\/p>\n<p>If you were to accidentally misuse this API, it would be pretty clear. When calling  <code class=\"language-text\">HeaderView<\/code> inside of  <code class=\"language-text\">SettingsViewController<\/code> the call-site is clean and simple. But if someone were to attempt to use it from another class, they would have to reference the fully-qualified type,  <code class=\"language-text\">SettingsViewController.HeaderView<\/code>.<\/p>\n<hr>\n<p>While I\u2019ve walked through one example with four approaches, binding a type to its context is something you can do throughout a codebase. In an ideal world Swift would have a <code class=\"language-text\">submodule<\/code> keyword to make types less ambiguous, but in the mean time this is a reasonable substitute that developers can take advantage of. While we don\u2019t have a <code class=\"language-text\">submodule<\/code> keyword, we have a close approximation by using empty enums. One notable example is Combine\u2019s usage of <a href=\"https:\/\/developer.apple.com\/documentation\/combine\/publishers\">Publishers<\/a> and <a href=\"https:\/\/developer.apple.com\/documentation\/combine\/subscribers\/\">Subscribers<\/a> to help people have context and understanding for their subtypes.<\/p>\n<p>As always, I\u2019d love to know what you think or if you\u2019ve come up with better solutions, so please don\u2019t be shy about <a href=\"https:\/\/twitter.com\/mergesort\">reaching out<\/a>.<\/p>\n<hr>\n<p>Special shoutout to <a href=\"https:\/\/twitter.com\/jasdev\">Jasdev<\/a> for taking a <em>very rough<\/em> first draft and helping me turn it into something coherent.<\/p>\n<\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10551\" class=\"pvc_stats total_only  \" data-element-id=\"10551\" style=\"\"><i class=\"pvc-stats-icon large\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/i0.wp.com\/dev95.site\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif?resize=16%2C16&#038;ssl=1\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<div id=\"dev95-1452845197\" class=\"dev95-after-content dev95-entity-placement\" role=\"region\" aria-label=\"\u0627\u0644\u0625\u0639\u0644\u0627\u0646\u0627\u062a\"><p style=\"text-align: center;\"><strong>Finally, a link that actually works for your region and device! \ud83c\udf0d Get instant access to the top exclusive offers tailored just for you right now. Don&#8217;t miss out, click here! \ud83d\udc47<\/strong><br data-sfc-root=\"ep\" data-sfc-pl=\"|||[]\" data-complete=\"true\" data-copy-service-computed-style=\"font-family: Arial, sans-serif, &quot;Noto Color Emoji&quot;; font-size: 16px; font-weight: 400; margin: 0px; text-decoration: none; border-bottom: 0px rgb(10, 10, 10);\" \/><a href=\"https:\/\/www.profitableratecpmnetwork.com\/uzeja8ahze?key=bc876be53d6ad0ff6370ab8ea030e479\"><strong>\ud83d\udd17 [Click here]<\/strong><\/a><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been thinking about privacy lately. No, not online privacy, but about how APIs can balance exposing the right amount of implementation details without revealing too much. I&#8217;ll walk through a task I find myself doing often when building iOS<\/p>\n<div class=\"hosteria-entry-more\"><a href=\"https:\/\/dev95.site\/ar\/context-bound-types\/\" class=\"no-underline font-light  group-hover:text-primary-800 dark:group-hover:text-primary-300 py-1\">Read more &gt;&gt;&gt;<\/a><\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10551\" class=\"pvc_stats total_only\" data-element-id=\"10551\" style=\"\"><i class=\"pvc-stats-icon large\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dev95.site\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=\"0\" \/><\/p>\n<div class=\"pvc_clear\"><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fp_fajr_begins":"","fp_fajr_iqamah":"","fp_dhuhr_begins":"","fp_dhuhr_iqamah":"","fp_asr_begins":"","fp_asr_iqamah":"","fp_maghrib_begins":"","fp_maghrib_iqamah":"","fp_isha_begins":"","fp_isha_iqamah":"","fp_midnight":"","fp_midnight_name":"","fp_sunrise":"","fp_single_prayer_begins_title":"","fp_single_prayer_iqamah_title":"","fp_prayer_times_for_today":"","fp_hijra_date":"","fp_fajr_name":"","fp_dhuhr_name":"","fp_asr_name":"","fp_maghrib_name":"","fp_isha_name":"","fp_sunrise_name":"","fp_currentDate":"","fp_current_time":"","fp_current_title":"","fp_current_location":"","fp_masjid_name":"","fp_prayer_title":"","fp_next_prayer_iqamah_time":"","fp_next_prayer_iqamah_title":"","fp_next_prayer_begins_time":"","fp_next_prayer_begins_title":"","fp_next_prayer_title":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[37],"tags":[],"class_list":["post-10551","post","type-post","status-publish","format-standard","hentry","category-posts"],"a3_pvc":{"activated":true,"total_views":4,"today_views":0},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Context-Bound Types - Dev95<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dev95.site\/ar\/context-bound-types\/\" \/>\n<meta property=\"og:locale\" content=\"ar_AR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Context-Bound Types - Dev95\" \/>\n<meta property=\"og:description\" content=\"I&#8217;ve been thinking about privacy lately. No, not online privacy, but about how APIs can balance exposing the right amount of implementation details without revealing too much. I&#8217;ll walk through a task I find myself doing often when building iOSRead more &gt;&gt;&gt;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dev95.site\/ar\/context-bound-types\/\" \/>\n<meta property=\"og:site_name\" content=\"Dev95\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-21T00:00:00+00:00\" \/>\n<meta name=\"author\" content=\"dev95\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0643\u064f\u062a\u0628 \u0628\u0648\u0627\u0633\u0637\u0629\" \/>\n\t<meta name=\"twitter:data1\" content=\"dev95\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u0648\u0642\u062a \u0627\u0644\u0642\u0631\u0627\u0621\u0629 \u0627\u0644\u0645\u064f\u0642\u062f\u0651\u0631\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u062f\u0642\u0627\u0626\u0642\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/\"},\"author\":{\"name\":\"dev95\",\"@id\":\"https:\\\/\\\/dev95.site\\\/#\\\/schema\\\/person\\\/b807805ffe2916206b04d0938bce0298\"},\"headline\":\"Context-Bound Types\",\"datePublished\":\"2020-09-21T00:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/\"},\"wordCount\":606,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/#organization\"},\"articleSection\":[\"Posts\"],\"inLanguage\":\"ar\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/\",\"url\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/\",\"name\":\"Context-Bound Types - Dev95\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/#website\"},\"datePublished\":\"2020-09-21T00:00:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/#breadcrumb\"},\"inLanguage\":\"ar\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev95.site\\\/context-bound-types\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev95.site\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Context-Bound Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev95.site\\\/#website\",\"url\":\"https:\\\/\\\/dev95.site\\\/\",\"name\":\"Dev95\",\"description\":\"Your comprehensive digital platform for knowledge, services, tools, and entertainment.\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/dev95.site\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ar\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev95.site\\\/#organization\",\"name\":\"Dev95\",\"url\":\"https:\\\/\\\/dev95.site\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ar\",\"@id\":\"https:\\\/\\\/dev95.site\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/dev95.site\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/rbrrbr-6.png?fit=512%2C512&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/dev95.site\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/rbrrbr-6.png?fit=512%2C512&ssl=1\",\"width\":512,\"height\":512,\"caption\":\"Dev95\"},\"image\":{\"@id\":\"https:\\\/\\\/dev95.site\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev95.site\\\/#\\\/schema\\\/person\\\/b807805ffe2916206b04d0938bce0298\",\"name\":\"dev95\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ar\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g\",\"caption\":\"dev95\"},\"url\":\"https:\\\/\\\/dev95.site\\\/ar\\\/author\\\/mohammad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Context-Bound Types - Dev95","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dev95.site\/ar\/context-bound-types\/","og_locale":"ar_AR","og_type":"article","og_title":"Context-Bound Types - Dev95","og_description":"I&#8217;ve been thinking about privacy lately. No, not online privacy, but about how APIs can balance exposing the right amount of implementation details without revealing too much. I&#8217;ll walk through a task I find myself doing often when building iOSRead more &gt;&gt;&gt;","og_url":"https:\/\/dev95.site\/ar\/context-bound-types\/","og_site_name":"Dev95","article_published_time":"2020-09-21T00:00:00+00:00","author":"dev95","twitter_card":"summary_large_image","twitter_misc":{"\u0643\u064f\u062a\u0628 \u0628\u0648\u0627\u0633\u0637\u0629":"dev95","\u0648\u0642\u062a \u0627\u0644\u0642\u0631\u0627\u0621\u0629 \u0627\u0644\u0645\u064f\u0642\u062f\u0651\u0631":"4 \u062f\u0642\u0627\u0626\u0642"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dev95.site\/context-bound-types\/#article","isPartOf":{"@id":"https:\/\/dev95.site\/context-bound-types\/"},"author":{"name":"dev95","@id":"https:\/\/dev95.site\/#\/schema\/person\/b807805ffe2916206b04d0938bce0298"},"headline":"Context-Bound Types","datePublished":"2020-09-21T00:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/dev95.site\/context-bound-types\/"},"wordCount":606,"commentCount":0,"publisher":{"@id":"https:\/\/dev95.site\/#organization"},"articleSection":["Posts"],"inLanguage":"ar","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dev95.site\/context-bound-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dev95.site\/context-bound-types\/","url":"https:\/\/dev95.site\/context-bound-types\/","name":"Context-Bound Types - Dev95","isPartOf":{"@id":"https:\/\/dev95.site\/#website"},"datePublished":"2020-09-21T00:00:00+00:00","breadcrumb":{"@id":"https:\/\/dev95.site\/context-bound-types\/#breadcrumb"},"inLanguage":"ar","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dev95.site\/context-bound-types\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dev95.site\/context-bound-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dev95.site\/"},{"@type":"ListItem","position":2,"name":"Context-Bound Types"}]},{"@type":"WebSite","@id":"https:\/\/dev95.site\/#website","url":"https:\/\/dev95.site\/","name":"Dev95","description":"\u0645\u0646\u0635\u062a\u0643 \u0627\u0644\u0631\u0642\u0645\u064a\u0629 \u0627\u0644\u0634\u0627\u0645\u0644\u0629 \u0644\u0644\u0645\u0639\u0631\u0641\u0629 \u0648\u0627\u0644\u062e\u062f\u0645\u0627\u062a \u0648\u0627\u0644\u0623\u062f\u0648\u0627\u062a \u0648\u0627\u0644\u062a\u0631\u0641\u064a\u0647.","publisher":{"@id":"https:\/\/dev95.site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dev95.site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ar"},{"@type":"Organization","@id":"https:\/\/dev95.site\/#organization","name":"Dev95","url":"https:\/\/dev95.site\/","logo":{"@type":"ImageObject","inLanguage":"ar","@id":"https:\/\/dev95.site\/#\/schema\/logo\/image\/","url":"https:\/\/i0.wp.com\/dev95.site\/wp-content\/uploads\/2026\/07\/rbrrbr-6.png?fit=512%2C512&ssl=1","contentUrl":"https:\/\/i0.wp.com\/dev95.site\/wp-content\/uploads\/2026\/07\/rbrrbr-6.png?fit=512%2C512&ssl=1","width":512,"height":512,"caption":"Dev95"},"image":{"@id":"https:\/\/dev95.site\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dev95.site\/#\/schema\/person\/b807805ffe2916206b04d0938bce0298","name":"dev95","image":{"@type":"ImageObject","inLanguage":"ar","@id":"https:\/\/secure.gravatar.com\/avatar\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a70a73d950838b20cd80d7ebdc955737e802e8cd896044c5473b32b946c0662a?s=96&d=mm&r=g","caption":"dev95"},"url":"https:\/\/dev95.site\/ar\/author\/mohammad\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/posts\/10551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/comments?post=10551"}],"version-history":[{"count":0,"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/posts\/10551\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/media?parent=10551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/categories?post=10551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev95.site\/ar\/wp-json\/wp\/v2\/tags?post=10551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}