<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jaume Viñas Navas on Medium]]></title>
        <description><![CDATA[Stories by Jaume Viñas Navas on Medium]]></description>
        <link>https://medium.com/@jaumevn?source=rss-a84912441ecc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EMXC57uLEc909jZ8tW1eeQ@2x.jpeg</url>
            <title>Stories by Jaume Viñas Navas on Medium</title>
            <link>https://medium.com/@jaumevn?source=rss-a84912441ecc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:00:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaumevn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JET8 Dev Update — June 6th, 2018]]></title>
            <link>https://medium.com/jet8-token/jet8-dev-update-june-6th-2018-cd3c81b705f?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd3c81b705f</guid>
            <category><![CDATA[news-articles]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dev-update]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Wed, 06 Jun 2018 16:00:13 GMT</pubDate>
            <atom:updated>2018-07-06T09:09:01.298Z</atom:updated>
            <content:encoded><![CDATA[<h4>Development progress and product changes from JET8</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkRZRhNZckI4TeNgifizUA.png" /></figure><h3>J8T Presale Bonus Distribution</h3><p>Today is the three-month mark since the successful conclusion of the J8T Token Sale.</p><p>As is outlined in the J8T whitepaper, the presale bonus Tokens are to be distributed in two equal parts, at 3 and 6 months after the end of the Token Sale.</p><p>We’re excited to announce that this distribution has started, and we are looking forward to continuing our commitment to both the community and the objectives outlined in the whitepaper.</p><h3>JET8 Architecture</h3><p>Work on the migration from monolith core to micro services continues as planned. We have finished testing and started deploying into production the dashboard, API&amp; shop independent services. More decoupled services will be deployed during the next weeks.</p><h3>About us</h3><p>For more information about <a href="https://jet8.io/">JET8</a>:</p><ul><li>Read the <a href="https://jet8.io/downloads/180223_J8T_Whitepaper_ENG.pdf">Whitepaper</a>and <a href="https://jet8.io/downloads/180223_J8T_One_Pager_ENG.pdf">One Pager</a></li><li>Subscribe to our <a href="https://www.reddit.com/r/JET8/">subreddit</a></li><li>Follow us on <a href="https://twitter.com/jet8app">Twitter</a></li><li>Join our <a href="https://t.me/Jet8_ecosystem">Telegram</a></li><li>Find us on <a href="http://github.com/jet8">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd3c81b705f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jet8-token/jet8-dev-update-june-6th-2018-cd3c81b705f">JET8 Dev Update — June 6th, 2018</a> was originally published in <a href="https://medium.com/jet8-token">JET8</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JET8 Dev Update — May 8th, 2018]]></title>
            <link>https://medium.com/jet8-token/jet8-dev-update-may-8th-2018-7090b8143b9f?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/7090b8143b9f</guid>
            <category><![CDATA[news-articles]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dev-update]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Tue, 08 May 2018 13:05:29 GMT</pubDate>
            <atom:updated>2018-05-08T14:22:18.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>JET8 Dev Update — May 8th, 2018</h3><h4>Development progress and product changes from JET8</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iD4725qd6Mts1dur.png" /></figure><h3>User Data Exchange Protocol</h3><p>The User Data Exchange Protocol (UDEP) creates an open marketplace where users and brands can decide between themselves when and how to exchange data. Users are prompted in-app to decide whether or not to share their data, and are rewarded when they do.</p><p>The UDEP currently rewards users only when they redeem products at retail stores such as Circle K and 7-Eleven. They are prompted in-app after they redeem the product and given the option to share their data with the specific brand.</p><p>We have started working on improving the UDEP SDK to a modular system. This new approach will open the possibility for users and brands to decide when and how to exchange data, and not limiting the interaction just to when users redeem products at a retail store.</p><p>More information about the UDEP transition to the new modular scheme will be announced during the upcoming weeks.</p><h3>JET8 Architecture</h3><p>Work continues on the migration of the monolith core to micro services as we get closer to our goal of making all services independent and interconnected.</p><p>During the past fortnight, we’ve completed the decoupling of the core to an independent package and started testing the first independent services: API, Data Processor, Wallet &amp; Shop.</p><h3>About us</h3><p>For more information about <a href="https://jet8.io/">JET8</a>:</p><ul><li>Read the <a href="https://jet8.io/downloads/180223_J8T_Whitepaper_ENG.pdf">Whitepaper</a>and <a href="https://jet8.io/downloads/180223_J8T_One_Pager_ENG.pdf">One Pager</a></li><li>Subscribe to our <a href="https://www.reddit.com/r/JET8/">subreddit</a></li><li>Follow us on <a href="https://twitter.com/jet8app">Twitter</a></li><li>Join our <a href="https://t.me/Jet8_ecosystem">Telegram</a></li><li>Find us on <a href="http://github.com/jet8">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7090b8143b9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jet8-token/jet8-dev-update-may-8th-2018-7090b8143b9f">JET8 Dev Update — May 8th, 2018</a> was originally published in <a href="https://medium.com/jet8-token">JET8</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JET8 Dev Update — April 10th, 2018]]></title>
            <link>https://medium.com/jet8-token/jet8-dev-update-april-10th-2018-e5201638bf0d?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5201638bf0d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[news-articles]]></category>
            <category><![CDATA[dev-update]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Tue, 10 Apr 2018 09:27:05 GMT</pubDate>
            <atom:updated>2018-04-11T14:54:49.587Z</atom:updated>
            <content:encoded><![CDATA[<h4>Development progress and product changes from JET8</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQBjU3VWQRLrHjUwzcM4Nw.png" /></figure><h3>JET8 Platform</h3><h4><strong>JET8 Architecture</strong></h4><p>We’re making massive improvements to the platform to keep scaling: going from a big monolithic to an independent services architecture, in order to allocate all the different services: Metrics &amp; Reports, Assets Manager, Content Moderation, Social Engagement Tracker, Community Manager, Apps as a Service, Shop &amp; API.</p><h4><strong>JET8 and the Blockchain</strong></h4><p>We’re excited enhance our platform with the integration of the blockchain and the J8T Token. Our first goal is the use of the blockchain as a trust authority in order to guarantee the immutability of data and therefore increased transparency for the JET8 community.</p><p>We’re currently implementing and testing our first product iteration in our development environments. We are starting to save general information about the social engagement generated on the JET8 platform to the blockchain.</p><p>More information about the blockchain transition and the uses of J8T Token will be announced during the upcoming weeks.</p><h4><strong>JET8 SDK</strong></h4><p>The JET8 SDK interacts with graphic formats such as JPEG, PNG, GIF and APNG to load and render both static and animated assets. During the last few months, we’ve been using the <a href="https://github.com/onevcat/APNGKit">APNGKit</a> library in order to load and display APNG files in the JET8 Asset Marketplace. We realized that the library doesn’t render animated assets consistently, and there are fringe cases where it doesn’t behave as expected.</p><p>In order to mitigate this issue and to increase loading and rendering performance, we are migrating from <a href="https://github.com/onevcat/APNGKit">APNGKit</a> to <a href="https://github.com/wangjwchn/AImage">AImage</a>. The AImage library provides a better APNG decoding performance and renders all animations correctly and consistently. The migration will be completed within the upcoming weeks.</p><h3>J8T Bounty Airdrop</h3><p>We’re happy to announce that the bounty airdrop distribution has officially started. People who participated in the Telegram Bounty Bot Program or the J8T Bounty App Program will start receiving the airdrop in the next two weeks.</p><p>To do so, we’ve created a script in order to automatize airdrop distribution. The script distributes J8T Tokens according to a CSV file which contains all approved bounty allocations (including addresses and amounts). The script distributes the J8T Tokens through the Custodian smart contract which safeguards all the J8T Bounty Token allocations.</p><p>The script has been written using Node.js and <a href="https://github.com/ethereum/web3.js/">Web3.js</a> to interact with the Ethereum blockchain, <a href="http://truffleframework.com/">Truffle</a> framework utilities such as <a href="https://github.com/trufflesuite/truffle-contract">truffle-contract</a> to interact with deployed contracts and <a href="https://github.com/trufflesuite/truffle-hdwallet-provider">truffle-hdwallet-provider</a> to sign transactions.</p><p>If you want to learn more about the code, check it out on <a href="https://github.com/jet8/bounty-airdrop">Github</a>.</p><h3>About us</h3><p>For more information about <a href="https://jet8.io/">JET8</a>:</p><ul><li>Read the <a href="https://jet8.io/downloads/180404_J8T_Whitepaper_ENG.pdf">Whitepaper</a> and <a href="https://jet8.io/downloads/180404_J8T_One_Pager_ENG.pdf">One Pager</a></li><li>Subscribe to our <a href="https://www.reddit.com/r/JET8/">subreddit</a></li><li>Follow us on <a href="https://twitter.com/jet8app">Twitter</a></li><li>Join our <a href="https://t.me/Jet8_ecosystem">Telegram</a></li><li>Find us on <a href="http://github.com/jet8">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5201638bf0d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jet8-token/jet8-dev-update-april-10th-2018-e5201638bf0d">JET8 Dev Update — April 10th, 2018</a> was originally published in <a href="https://medium.com/jet8-token">JET8</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JET8 Dev Update — March 26th, 2018]]></title>
            <link>https://medium.com/jet8-token/jet8-dev-update-03-26-2018-4f64bf9df3d1?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f64bf9df3d1</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dev-update]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[news-articles]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Mon, 26 Mar 2018 16:08:20 GMT</pubDate>
            <atom:updated>2018-04-11T14:55:40.315Z</atom:updated>
            <content:encoded><![CDATA[<h3>JET8 Dev Update — March 26th, 2018</h3><h4>Development progress and product changes from JET8</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPXm4qVGUe5pRCjlp14x7Q.png" /></figure><h3>Introducing animated frames to the JET8 Ecosystem</h3><p>From the initial conception of the JET8 Ecosystem, we always envisioned artists creating their work without technical limitations. Today we’re happy to announce that a new type of asset has joined the JET8 Ecosystem: animated frames. The greater the variety of assets the JET8 platform supports, the greater the possibilities for users to create great content, feel closer to brands, and generate more engagement. The better the content, the more the engagement, the more JET Points earned.</p><p>With this new addition, the JET8 Ecosystem now supports four different types of assets: static stickers, animated stickers, static frames and animated frames.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ReQevSokXlen0n70-NrmuA.gif" /><figcaption>From left to right, static sticker, animated sticker, static frame and animated frame.</figcaption></figure><p>The JET8 platform supports the most common graphic file formats, but we highly recommend the <a href="https://wiki.mozilla.org/APNG_Specification">APNG</a> format for animated assets. Using the APNG format significantly improves the performance when loading and rendering animated images on mobile devices, as well as improved data usage compared to other graphic formats (such as GIF). Additionally, APNG files are a better solution for creatives as they support a greater variety of options such as 24-bit images and 8-bit transparency.</p><h3>How to use animated frames?</h3><p>You can start using your favorite animated frames the same way you would with any other asset type. Start by opening any of the apps already on the JET8 Ecosystem. Take a selfie, or video selfie. Choose your favorite asset from the JET8 asset marketplace. And share it to your social media.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*o5clmsdQShvo7FaEaoBGCw.gif" /></figure><h3>Can people start earning JET Points with animated frames?</h3><p>Absolutely! We’re a working product company with a variety of app communities already using our platform to connect with brands and earn JET Points with the engagement users generate.</p><p>Content published and shared to popular social media, including Facebook, Twitter and Instagram increases brand reach and potential engagement. The more people content creators reach the more JET Points they earn with each like, share and comment their content receives.</p><p><strong>Fotoku</strong> is the first app compatible with animated frames, you can download it now from the <a href="https://itunes.apple.com/es/app/fotoku/id936697701?l=en&amp;mt=8">App Store</a> and <a href="https://play.google.com/store/apps/details?id=com.fotoku.mobile&amp;hl=en">Google Play</a>.</p><h3>What’s next?</h3><p>We have plans to include more asset types in future updates in order to enhance our platform and therefore improve our network of apps, creators and influencers. Expect to see more updates in the near future.</p><h3>About us</h3><p>For more information about <a href="https://jet8.io/">JET8</a>:</p><ul><li>Read the <a href="https://jet8.io/downloads/180404_J8T_Whitepaper_ENG.pdf">Whitepaper</a> and <a href="https://jet8.io/downloads/180404_J8T_One_Pager_ENG.pdf">One Pager</a></li><li>Subscribe to our <a href="https://www.reddit.com/r/JET8/">subreddit</a></li><li>Follow us on <a href="https://twitter.com/jet8app">Twitter</a></li><li>Join our <a href="https://t.me/Jet8_ecosystem">Telegram</a></li><li>Find us on <a href="http://github.com/jet8">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f64bf9df3d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jet8-token/jet8-dev-update-03-26-2018-4f64bf9df3d1">JET8 Dev Update — March 26th, 2018</a> was originally published in <a href="https://medium.com/jet8-token">JET8</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing JSON with Swift 4]]></title>
            <link>https://medium.com/@jaumevn/parsing-json-with-swift-4-abf6c1633cfd?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/abf6c1633cfd</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 16:50:42 GMT</pubDate>
            <atom:updated>2018-01-03T16:58:52.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*beWyjuOV7R4xrz6vtayYHg.png" /></figure><p>There are great libraries out there that help you parse JSON data, but it is great to see how Swift 4 implements a fully-native solution to make your data types encodable and decodable for compatibility with JSON.</p><p>There are three new protocols in the Swift standard library that define an standardized approach to data encoding and decoding. These new protocols are Encodable, Decodable and Codeble</p><h4>Encoding and Decoding</h4><p>The easiest way to encode or decode a type is to use standard properties that are already Codable, which can be types like String, Int, Double, Data, Date and URL.</p><p>Let’s consider a User structure that stores the name, the username and the phone number of a user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f822eb7362ddcdadc053af7efd4ba8fc/href">https://medium.com/media/f822eb7362ddcdadc053af7efd4ba8fc/href</a></iframe><p>We can make it automatically decodable and encodable by conforming to the Codable protocol, which is a type alias of Encodable and Decodable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/653a99bddcf652f1f04c8c0197293ecf/href">https://medium.com/media/653a99bddcf652f1f04c8c0197293ecf/href</a></iframe><p>We can also use custom types that also conform to the Codable protocol, and use built-in types such as Array, Dictionary and Optional whenever they contain codable types.</p><p>Let’s add to the previous example a list of devices that the user owns. It is represented by an Array of Device. The Device stores the name and the manufacturer of a device.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d642c2d75d1cf5dacb6b0e5459ed95cd/href">https://medium.com/media/d642c2d75d1cf5dacb6b0e5459ed95cd/href</a></iframe><p>We can now deserialize a JSON document into our User instance, and serialize that instance back into a JSON document.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79597b7945958f656c3ad01d5316e698/href">https://medium.com/media/79597b7945958f656c3ad01d5316e698/href</a></iframe><h4>Encode or Decode Exclusively</h4><p>In some cases, you may not need to decode and encode the same type. For example, you may only need to read data and decode them into an instance, or you just need to make API calls and there is no need to decode the response containing the same type.</p><p>You can achieve that by conforming Encodable and Decodable protocols. The example below shows how the User structure only encode data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2309ad743e29d177d2aa0b2b45519cab/href">https://medium.com/media/2309ad743e29d177d2aa0b2b45519cab/href</a></iframe><h4>Custom Key Names</h4><p>It is often the case that we parse JSON documents with properties that doesn’t match our property names. In that case, we need to define custom key names in order to parse these properties into our instances.</p><p>In order to define the custom list of key names we need to define an enumeration named CodingKeys which conforms to the CodingKeys protocol. The names of the enumeration cases should match the names you’ve given to the corresponding properties in your type.</p><p>Let’s update the property phoneNumber of our User structure, which is defined in the JSON document using snake-case style. The enumeration CodingKeys provide the phoneNumber alternative key specified by a String as the raw-value type for the CodingKeys enumeration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9586d8c8f450865d1d7a26c0ee796f95/href">https://medium.com/media/9586d8c8f450865d1d7a26c0ee796f95/href</a></iframe><p>If you find this post helpful, please recommend it for others to read. And remember that all the code of this article can be found at <a href="https://swift.cat/parsing-json-with-swift-4/">SwiftCat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abf6c1633cfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Enumerations (Part 3)]]></title>
            <link>https://medium.com/@jaumevn/swift-enumerations-part-3-d49f5ce7731b?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d49f5ce7731b</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Thu, 16 Nov 2017 18:31:02 GMT</pubDate>
            <atom:updated>2017-12-24T16:20:21.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5AZFk4lExXHm9MCmQFCKw.png" /></figure><p>Swift <em>enumerations</em> are a first-class types in their own right, that means they can adopt many features traditionally supported only by classes. In this chapter we will cover how enumeration can define custom initializers to provide an initial case value, and how they can be extended and conform to protocols.</p><p>Remember to read the first chapters (<a href="https://medium.com/@jaumevn/swift-enums-f17f13b9999f">Part 1</a> and <a href="https://medium.com/@jaumevn/swift-enumerations-part-2-9f6568827b16">Part 2</a>) if you missed them or you want to refresh the basic concepts of Swift <em>enums</em>.</p><h4>Protocols</h4><p>A <em>protocol </em>defines an interface of methods, properties and other requirements that can be adopted by a class, structure or enumeration. Any type that satisfies the requirement of a protocol must provide an implementation of those requirements.</p><p>For demonstration purposes we use the LayerActions enumeration declared in the previous <a href="https://medium.com/@jaumevn/swift-enumerations-part-2-9f6568827b16">chapter</a>, which defines a set of actions that users can execute in order to modify a layer in a design tool. To execute and describe each action we declare the protocol Taskable, which defines a method to execute a task and a description property that defines the task to be executed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2963682e0af8851cfdb4979ee1aec09f/href">https://medium.com/media/2963682e0af8851cfdb4979ee1aec09f/href</a></iframe><p>As you can see, the enumeration now conforms to the protocol requirements in the enumeration by implementing the method execute() and the computed property description.</p><h4>Extensions</h4><p>An <em>extension</em> adds new functionality to an existing class, structure, enumeration or protocol type. You can use an extension to add computed properties, define methods, define initializers, or make the existing type conform to a protocol among others.</p><p>In our case, we will extend the LayerActions enumeration to conform the protocol Taskable and make it easier to read, understand and maintain the code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb004b5d57f2de3d78df2844d69a7b68/href">https://medium.com/media/cb004b5d57f2de3d78df2844d69a7b68/href</a></iframe><p>We can add as many extensions as we want, for instance, we can extend the previous enumeration in order to implement a different protocol. Here’s an example that extends the enumeration twice to separate the implementation of protocols Taskable and Serializable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a6d199986e4f837b2b083c0d2acd5cb/href">https://medium.com/media/3a6d199986e4f837b2b083c0d2acd5cb/href</a></iframe><h4>Initializers</h4><p>Enumerations with a raw-value type automatically receive an initializer that takes as a parameter a value of the raw value’s type. Here’s an example of an enumeration with a raw-value type that uses the initializer to create a new instance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f57df6e3b8656b708e39b8c53783f3af/href">https://medium.com/media/f57df6e3b8656b708e39b8c53783f3af/href</a></iframe><p>Initilizers return either an enumeration case or nil. As you can see in the following example, the variable q is of type Polygon? and the value returned by the raw initializer is nil.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/952f9403d2be0b7b1fe5773fbcb46c17/href">https://medium.com/media/952f9403d2be0b7b1fe5773fbcb46c17/href</a></iframe><p>You can also create custom initializers even if the enumeration is not a raw-value typed enumeration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b31b1f00b9b6491dc8006cc1b2543f5/href">https://medium.com/media/1b31b1f00b9b6491dc8006cc1b2543f5/href</a></iframe><p>If you find this post helpful, please recommend it for others to read.</p><p>This article was originally published on <a href="https://swift.cat/swift-enumerations-part-3/">swift.cat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d49f5ce7731b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Enumerations (Part 2)]]></title>
            <link>https://medium.com/@jaumevn/swift-enumerations-part-2-9f6568827b16?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f6568827b16</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Sun, 12 Nov 2017 11:01:32 GMT</pubDate>
            <atom:updated>2017-12-24T16:19:10.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YU51dP0vV7Bw_fRFkQly1A.png" /></figure><p>In this new chapter we will cover more advanced features about Swift enumerations, remember to <a href="https://medium.com/@jaumevn/swift-enums-f17f13b9999f">read</a> the first chapter if you missed it or you want to refresh the basic concepts of Swift <em>enums</em>.</p><h4>Associated Values</h4><p>Enumeration cases have their own value and type, and sometimes it is useful to store additional data of other types alongside an enum case. <em>Associated values</em> are a fantastic way to achieve that by attaching custom information along with the case value, allowing this information to be different each time you use that enum case in your code.</p><p>Here’s an example of an enumeration that defines a set of actions that users can execute in order to modify a layer. A layer can be resized, rotated and filled with a color. The enum case resize has two associated values that define the new width and height values of the layer, the enum case rotate has one associated value which indicates the rotation degrees, and the enum case fill has one associated value that indicates the color of the layer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bae0d68fa93213a354a008fbaddfd0bb/href">https://medium.com/media/bae0d68fa93213a354a008fbaddfd0bb/href</a></iframe><p>The associated values can be accessed using a switch statement, and they can be extracted as constants (with the let prefix) or as variables (with the var prefix).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e028c4f94a712d4891f22bdcf257edd/href">https://medium.com/media/9e028c4f94a712d4891f22bdcf257edd/href</a></iframe><h4>Methods</h4><p>Enumerations in Swift are first-class types in their own right. They adopt many features traditionally supported only by classes, for example, instance methods to provide functionality related to the values the enumeration represents.</p><p>Methods on enumerations exist for every enum case. If you want to provide specific code for every enum case, you need a switch statement to determine each case.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ca10ff0dcc7a62c17fba384bfadcc25/href">https://medium.com/media/6ca10ff0dcc7a62c17fba384bfadcc25/href</a></iframe><h4>Mutating Methods</h4><p>By default, the properties of an enumeration cannot be modified from within its instance methods. However, if you need to modify your enumeration you can use mutating methods. Mutating methods for enumerations can set the implicit self parameter to be a different case from the same enumeration.</p><p>Here’s an example that defines an enumeration for a temperature alarm with two states, enabled and disabled. The enumeration changes its state when the temperature reaches an specific threshold.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c4328baf14afb654cc007f0e7fa8aaa/href">https://medium.com/media/6c4328baf14afb654cc007f0e7fa8aaa/href</a></iframe><h4>Properties</h4><p>Event though enumerations can’t have stored properties, they can have computed properties to provide additional information about the enumeration’s current value.</p><p>The example below modifies the Polygon enumeration in order to add a new property edges . This new property returns the number of edges of the enum case. The method description() has also been updated in order to use the new property.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7e529d0d1290b66cdf5dd1d2a9080d4/href">https://medium.com/media/b7e529d0d1290b66cdf5dd1d2a9080d4/href</a></iframe><p>If you find this post helpful, please recommend it for others to read. In the next chapter we will cover more advanced enumeration usages such as protocols, extensions, generics and custom initializers.</p><p>This article was originally <a href="https://swift.cat/swift-enumerations-part-2/">swift.cat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f6568827b16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Enumerations (Part 1)]]></title>
            <link>https://medium.com/@jaumevn/swift-enums-f17f13b9999f?source=rss-a84912441ecc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f17f13b9999f</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Jaume Viñas Navas]]></dc:creator>
            <pubDate>Fri, 10 Nov 2017 18:05:17 GMT</pubDate>
            <atom:updated>2017-12-24T16:18:03.038Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQV8eeZ5poSvhTvTZOJbNg.png" /></figure><p>An <em>enumeration</em> defines a custom data type for a set of related values. Swift enumerations are much more flexible and powerful than we got used to in other languages. Enumerations in Swift are first-class type in their own right, they support computed properties, instance methods, custom initializers, extensions and can conform to protocols.</p><h4>Syntax</h4><p>Swift enumerations are introduced with the enum keyword and writing their entire definition within a pair of braces. Here’s an example that defines some different types of polygons:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d475adf5a0360c1513578992e2676b68/href">https://medium.com/media/d475adf5a0360c1513578992e2676b68/href</a></iframe><p>Multiple cases can be arranged on a single line separated by comas:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5420d80749f0fd2d1dd806de45081842/href">https://medium.com/media/5420d80749f0fd2d1dd806de45081842/href</a></iframe><p>You can match enumerations with various pattern matching constructs to retrieve the value of the enum, or act upon a specific case. Here’s an example that prints the number of sides of the polygon for an specific case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83851fbe9725c3d4a994a378488cfda/href">https://medium.com/media/f83851fbe9725c3d4a994a378488cfda/href</a></iframe><p>A switch declaration must be exhaustive when considering an enumeration’s cases. If one of the cases of the enum is omitted in the switch declaration the code will not compile. If you don’t need to provide a case for every enumeration case, you can provide a default case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/655793d2da66c1ce0d993c70053fe7e2/href">https://medium.com/media/655793d2da66c1ce0d993c70053fe7e2/href</a></iframe><p>When a variable is initialized with one of the possible values of an enumeration, the type is automatically inferred. In the following example, the variable figure contains the enum value triangle and so it automatically infers its type, Polygon. We can then set it to a different Polygon value using dot syntax:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddb57361e9d0c66ac97a922bad02712f/href">https://medium.com/media/ddb57361e9d0c66ac97a922bad02712f/href</a></iframe><h4>Raw Values</h4><p>Enumerations can have a value assigned to each case. Swift supports Integer, Floating Point, String and Boolean types for the value of an enum. You can access to the value assigned to each enumeration case with the rawValue property.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02e4287182ce13156d506cc226da4c52/href">https://medium.com/media/02e4287182ce13156d506cc226da4c52/href</a></iframe><h4>Nested enums</h4><p>Enums can be nested in order to specify sub types. To nest a type within another type you must declare its entire definition within the outer pair of braces.</p><p>Following the previous example, we can consider two new specific sub types for the triangle enum case. Triangles can be classified by various properties relating to their angles and sides. Here’s an example that classifies triangles by their sides:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e67f61e155630a55414fc005d22afa3e/href">https://medium.com/media/e67f61e155630a55414fc005d22afa3e/href</a></iframe><p>Nested types can be used outside its definitions context using the dot syntax. You must prefix its name with the name of the type it is nested within:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07dca286e2303e747b5ab95326170661/href">https://medium.com/media/07dca286e2303e747b5ab95326170661/href</a></iframe><p>If you find this post helpful, please recommend it for others to read. In the next chapter we will cover more advanced features such as associated values, methods and properties. This article was originally published on <a href="http://swift.cat/swift-enumerations-part-1">swift.cat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17f13b9999f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>