<?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 Emrah on Medium]]></title>
        <description><![CDATA[Stories by Emrah on Medium]]></description>
        <link>https://medium.com/@itseemrah?source=rss-2b71df906c00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1VIZkB4BBYvK6uTk5tYDcw.jpeg</url>
            <title>Stories by Emrah on Medium</title>
            <link>https://medium.com/@itseemrah?source=rss-2b71df906c00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:42:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@itseemrah/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[Facade Design Pattern in Swift iOS, with the usage of Dependency Injection & ViewModel]]></title>
            <link>https://blog.devgenius.io/facade-design-pattern-in-swift-ios-with-the-usage-of-dependency-injection-viewmodel-3ed3983b58d8?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ed3983b58d8</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[facade]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 18:05:47 GMT</pubDate>
            <atom:updated>2023-02-22T18:05:47.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KAfSEZLYGw8o4GR4pNTEoQ.png" /><figcaption>Swift Language Icon</figcaption></figure><h4>Introduction</h4><p>Design patterns exist because, in the software development world, there are tons of different types of problems, so you can solve these problems in many different ways/approaches, there are no certain limitations on implementations of these patterns, you can implement and use these patterns with many similar ways, I will not touch detailed in what design patterns is, how different patterns between each other, I am writing the blog for Facade Design Pattern is a Structural Pattern.</p><p>I will talk about Facade, then a little bit of Dependency Injection in ViewModel, and we will cover an example on top of these stacks and will apply Facade.</p><p>Before we jump in, I want to share a cool <a href="https://serialcoder.dev/text-tutorials/software-engineering/design-patterns/the-facade-design-pattern-in-swift/">blog post</a> that can help you to better explanations for Facade Design Patterns in iOS.</p><h3>What is FACADE?</h3><p>Basically, a Facade is a design pattern in Software Engineering, if you go to Wikipedia for Facade, you will see this sentence</p><blockquote>A facade is an <a href="https://en.wikipedia.org/wiki/Object_(computer_science)">object</a> that serves as a front-facing interface masking more complex underlying or structural code.</blockquote><p>Now let’s think that when the sentence says is an object, it can be an interface, protocol, or object that combines complex structures to an interface, protocol, or again an object. Let’s think that you’re an automotive engineer, you’ve created an automobile, and from your perspective, there are tons of paradigms and complex jobs for making an automobile run, but you have to mask the all complexity to just 3 things in the manual; <strong><em>gas, brake, clutch </em></strong>for make it easy to use and maintainable.</p><h4>A Mock Example</h4><p>From a software engineering perspective, let’s think that we have a <strong>Markdown Preview</strong> task, our jobs are:</p><ul><li>download Markdown data from the internet</li><li>parse downloaded Markdown data</li><li>cache parsed Markdown data</li><li>show cached Markdown data in UITextView</li></ul><p>I am creating these jobs into different functionality, let’s look at our example</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/369c04811d2728172c1acc6c553aa8d9/href">https://medium.com/media/369c04811d2728172c1acc6c553aa8d9/href</a></iframe><p>Now, let’s look at the definition of Facade again,</p><blockquote>interface masking more complex underlying or structural code.</blockquote><p>an interface masking more complex underlying or structural code.</p><p>So, the <strong>Facade Design Pattern</strong> says this, hey developer; you’ve created a bunch of functions, a bunch of classes, and structs in <strong>MarkdownPreviewViewController</strong>, why don’t you create a class or struct to combine all of this works into just one functionality, and why don’t you hide all of this complex functionality into an object/interface?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*SMEmV2AIBB9EE_s8nSB49w.png" /><figcaption><a href="https://www.geeksforgeeks.org/facade-design-pattern-introduction/">https://www.geeksforgeeks.org/facade-design-pattern-introduction/</a></figcaption></figure><p>Before I keep deep dive into the Facade example, let’s look at this awesome diagram; when you remove the Facade interface from the middle, you have to create some functionality and combine all Subsystems with each other to make the job done, and all clients have to know about all Subsystems, but we are doing software engineering, why don’t we isolate our code from the user/client? Let’s think that you’ve created a module for Markdown, should the user/client/developer know about all stuff going on in there, or should we isolate our code and give an interface for communication between the module and clients for users?</p><p>Let’s convert our Markdown services into a Facade design pattern</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3860149efa31518e968fc9281b46ce66/href">https://medium.com/media/3860149efa31518e968fc9281b46ce66/href</a></iframe><p>We isolate all complexity into one class structure and now users only know the interface of MarkdownPreviewer which has only an open <strong>showMarkdown </strong>function, as the Facade Design Pattern implies.</p><h4>Dependency Injection + ViewModel + Facade</h4><p>We will examine an example of the ViewModel class which is using 2 different dependencies; one of it for Networking and another one is for Analytics, which is using 2 different jobs to combine within</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc0254444a5276b75ac7ad9010027bc6/href">https://medium.com/media/bc0254444a5276b75ac7ad9010027bc6/href</a></iframe><p>We basically have a view model class for profile view controller, it’s a dummy, so network and analytics tagger is used with dependency injection to this class however I want to change our perspectives, let’s look at its usage in a controller.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70927403f59736fe832bac2121b08645/href">https://medium.com/media/70927403f59736fe832bac2121b08645/href</a></iframe><p>We have to create 2 different dependencies to use the view model for the profile screen, one of the dependencies is working for network tasks, and another one is for sending analytics tags as network fetch results, so when you look at it from this point you can say that we isolate the functionality, the user just only reaches to <strong>fetch<em>() </em></strong>method, but what about the view model itself? Remember the diagram above, multiple <strong>Clients</strong>, multiple <strong>Subsystems</strong>, between the <strong><em>Clients</em></strong> and the <strong><em>Subsystems</em></strong> there is a <strong>Facade</strong> structure, so let’s change the implementation of the <strong>ProfileViewModel</strong> and apply <strong>Facade Design Pattern</strong> for it too.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/816eb6bcb074fddbf4acd07f9dd72bf6/href">https://medium.com/media/816eb6bcb074fddbf4acd07f9dd72bf6/href</a></iframe><p>and usage of this updated view model is</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdd50465852848655e6d171c04aad6d6/href">https://medium.com/media/cdd50465852848655e6d171c04aad6d6/href</a></iframe><p>Maybe there are not many changes in the creation of <strong>ProfileViewModel</strong>, happily, we decrease the number of dependencies for <strong>ProfileViewModel,</strong> but the real change is in the view model itself, the view model worker aka <strong>ProfileViewModelWorker</strong> is using the power of the protocols like <strong><em>ProfileViewModelWorkable</em></strong>, <strong><em>ProfileNetworkFetchable</em></strong>, <strong><em>ProfileAnalyticTaggable</em></strong></p><h4>What we achieved?</h4><p>Let’s compare all we did on ViewModel, Dependencies from the Facade Design Pattern view.</p><p>First of all, we decrease the dependency count of the view model which is good, and the important one is that look at the code of the first edition of <strong>ProfileViewModel</strong>, there are 2 different dependencies, one of which is working for the network, and another is working for tagging analytics, but there’s no structure for isolation as <strong>Facade</strong> does, every function in the first scenario is used and combined with each other in regular functionality of the <strong>ProfileViewModel</strong> class, but right now, we created a solution based structure protocol which named <strong>ProfileViewModelWorkable,</strong> which is implemented by <strong>ProfileViewModelWorker,</strong> and now ViewModel is only use a structure between network+analytics and itself which named <strong>ProfileViewModelWorker</strong> is also known Facade module.</p><h3>Conclusions</h3><p>Funny thing is that Facade Design Pattern; is a pattern that you probably use every time when you are programming, creating data structures, or protocol/interface-oriented programming but maybe you don’t know it’s name.</p><p>In the first part of the article I wrote what is all about this pattern and I wanted to make it a little harder with Dependency Injection + ViewModel usage which is very common in the software engineering world.</p><p>Thanks for reading the article! I hope you like my article and that would be helpful and useful for all readers. Please feel free to comment about your thoughts, we can discuss about it, be safe 🤘🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ed3983b58d8" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/facade-design-pattern-in-swift-ios-with-the-usage-of-dependency-injection-viewmodel-3ed3983b58d8">Facade Design Pattern in Swift iOS, with the usage of Dependency Injection &amp; ViewModel</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XCFramework + SwiftPackageManager]]></title>
            <link>https://blog.devgenius.io/xcframework-swiftpackagemanager-c03f4b1903d9?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/c03f4b1903d9</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[spm]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[xcframework]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 00:55:49 GMT</pubDate>
            <atom:updated>2022-10-09T14:16:46.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0N3wx36PVnIvnOLxD2vxg.png" /><figcaption>Background of publication</figcaption></figure><p>You’ll read an article about how to make Framework, XCFramework, how to make Swift Package Manager, and how to use XCFramework with Swift Package Manager. I’ll cover all topics from the beginner level. I assume that you’ve basic knowledge of SwiftPackageManager and XCFrameworks.</p><p>First of all, I recommend to you watch 2 videos from <strong><em>developer.apple.com</em></strong></p><p>The first video <a href="https://developer.apple.com/videos/play/wwdc2019/416/">Binary Frameworks in Swift</a> and the second one is <a href="https://developer.apple.com/videos/play/wwdc2020/10147/">Distribute Binary Frameworks as Swift Packages</a> , you will like these videos I think, they are delicious 🍎</p><p>Yup, let’s start, when you read some articles about XCFramework, you must see the pre-compiled word in one of these articles, precompiled describe XCFramework, it’s basically a binary package of Apple worlds. You can see the key differences between them by looking at them in the Xcode Project navigator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*2yn6fRAdgyKEQYt25cgtdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*RXt8R7oN8UX0nzO11RAcKA.png" /><figcaption>Project Navigator of a simple project</figcaption></figure><p>Please focus Logger on the left image and LoginModule on the right image. Logger is a simple Swift Package, and LoginModule in the right is a simple XCFramework — binary package. You can look at the all includes, sources, and resources of SwiftPackage, but did you see that LoginModule is kinda like a locked box? So it’s a binary package newly named XCFramework which you can share your code as binary and nobody can see your code. SwiftPackageManager is really cool and easy to use, now we can XCFrameworks with it, so why we don’t use it?</p><h3>We need a scenario to build something</h3><p>I made a scenario to build something like that we are paid by X Company to build a ToDo SDK and we have to deliver our SDK to X Company, this ToDo SDK fetches ToDo’s and provides 3rd party login module for our ToDo integration but be careful, it’s just a small module, fetch and login stuff.</p><h3>Create XCFramework</h3><p>Like similar steps of the creation of an application for iOS, you will need to create a Framework for iOS first, then we will create our XCFramework!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wqwYWQCFScEhITzXCL16Bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-R67n4vC6JAmxUcJVg3bzQ.png" /></figure><p>Do not forget to remember the Bundle identifier of your XCFramework, we will use it later :) Now we successfully created our binary framework but we have to do something</p><p>I created a folder named Sources, then in the Sources folder, created Network and Login folders too, create a new Swift file in the Network folder and named it LoginNetwork, then create a Cocoa Touch Class and named LoginViewController and select the <strong>also create XIB file </strong>then create last of our files as named LoginViewModel. You can see down below what the project structures will be looking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*6RRrnX-j9kZZjCiVDH8x2A.png" /></figure><p>Let’s look our project files and look at LoginViewController XIB</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbfede00d10f8e58d88609ae8205644f/href">https://medium.com/media/cbfede00d10f8e58d88609ae8205644f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9513650b96193dc0ceafdeca2234c5d3/href">https://medium.com/media/9513650b96193dc0ceafdeca2234c5d3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/992f7a0612e0dd60f8741b4a17f75bd9/href">https://medium.com/media/992f7a0612e0dd60f8741b4a17f75bd9/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QSYUt0QgFgdoIFrct07Hdg.png" /></figure><p>LoginViewController contains a UIButton on the bottom and UILabel on the top, so this is so basic and meaningless page, but when you look at the IBAction functionality of the button, you will see that there’s a network call for fetching Todo from Todo API.</p><blockquote>As I wrote before, I just need a scenario, so do not take the scenario seriously,it’s just a fun framework for the article</blockquote><h3>Let’s get our hands dirty 🧑🏻‍💻</h3><p>So, first of our job is go to ToDoSDK target and select <em>Build Settings, </em>then find <strong>Build Libraries for Distribution</strong>, set it to <strong>YES</strong>, then build it.</p><p>We need to archive our TodoSDK for the iPhone simulator and iPhone os now, it’s necessary because we will create these archives to combine when we create XCFramework, and then we can use our ToDoSDK with Simulator and also the real device.</p><p>Use your terminal and go to the folder of the <strong>ToDoSDK</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52492ea73e93b5768bb0b7bc8ea4b4b8/href">https://medium.com/media/52492ea73e93b5768bb0b7bc8ea4b4b8/href</a></iframe><p>This code will archive our ToDoSDK into Desktop as a .xcarchive folder and as you can see, the target is the iPhone simulator, now we have to use it for real iphoneos.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6eee452651cb105e9a8112872c407d9/href">https://medium.com/media/a6eee452651cb105e9a8112872c407d9/href</a></iframe><p>And this archive command will archive our framework for iPhone os available. Now we have to combine this iPhone simulator + iPhone os archives into just one XCFramework and we can use it with singular XCFramework as a binary package.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1ca1c5b0edbca5dbd58f62b0556f3f3/href">https://medium.com/media/e1ca1c5b0edbca5dbd58f62b0556f3f3/href</a></iframe><p>Now this command will combine 2 frameworks into one XCFramework. Now we have our XCFrameworks in Desktop named ToDoSDK</p><h3>Usages of XCFramework</h3><p>There is more than one usage of the XCFramework for an application, first usage is that you can drag and drop it into your application, and import it to the project, let’s see the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5HAlB_rAgn2SRwtWkolmQ.png" /></figure><p>Let’s select copy items if needed and finish, you can import ToDoSDK and use it happily as I do in the tutorial project which you can see below with the screenshot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIiLf87yviI93sUxWXX4cg.png" /><figcaption>Happy Coding :)</figcaption></figure><h3>Benefits of it when you use Swift Package Manager</h3><p>Guys, did you see that I drag &amp; drop my XCFramework into the project, it’s a cool way but there are cooler ways to use and distribute because these packages must be distributed mostly in the projects, I mean packaging when I talk about distribution, for example, Swift Package Manager or CocoaPods, but we will cover Swift Package Manager for this article, with SPM we will encapsulate it a little bit more, we will add some wrapper classes to reach the functionality of ToDoSDK, some organizations use emails to send this binary packages, it would be cool to use binary packages</p><h4>Create a Swift Package</h4><p>After you select thew Xcode icon, select File -&gt; New -&gt; Package. Name it ToDoPackage. Create a folder named <strong>artifacts</strong> and drag and drop our precious XCFramework into this folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*OcYF3rAaJOI8HZbLCB-pwA.png" /><figcaption>It should like this</figcaption></figure><p>Then in the package, you must add ToDoSDK as <strong>binaryTarget</strong> and also add this binary dependency into our Library which is named <strong>ToDoPackage</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ad5772f343680e188d425b6e1e500b5/href">https://medium.com/media/5ad5772f343680e188d425b6e1e500b5/href</a></iframe><p>As you can see in the binaryTarget, there’s the exact name of ToDoSDK and its path, you finally add binary XCFramework to Swift Package but we need to add this binary package as targets for our library as seen in line 13.</p><h4>Implement Wrapper Functionality</h4><p>When you open the ToDoPackage folder at the bottom, you will see there’s a swift file named ToDoPackage, remove it and paste the code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa0fd65e8ce158911ee1633f04d5139f/href">https://medium.com/media/aa0fd65e8ce158911ee1633f04d5139f/href</a></iframe><p>In the photo, you can see a class and static function named <strong>getLoginViewController</strong> which returns <strong>LoginViewController</strong></p><p>If you click the ToDoSDK for info on the return side, you will see just interfaces of all structures of it like below, the implementation and details cannot be seen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b73ccaa04248ca674a81740905962236/href">https://medium.com/media/b73ccaa04248ca674a81740905962236/href</a></iframe><p>So we are on the right way, keep going…</p><p>Did you remember that at the beginning of the article I said that do not to forget the bundle identifier of the Framework?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa0fd65e8ce158911ee1633f04d5139f/href">https://medium.com/media/aa0fd65e8ce158911ee1633f04d5139f/href</a></iframe><p>In here for getting an instance of LoginViewController needs a Bundle, and Bundles are different in SwiftPackage and XCFramework, so for reaching LoginViewController you’ve to put the exact identifier of the Framework, do not forget it.</p><p>Right now, we can try our SwiftPackage peacefully at last. There’s more than one way to try our SwiftPackage. First of all, you can push the SwiftPackage into Github and then fetch the package from Xcode with Add Package option, or you can drag and drop, for this article, I am choosing the easy path and using drag &amp; drop.</p><p>I’ve created an empty app named TutorialApp and dragged&amp;dropped my ToDoPackage into the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rDV4KFY7NLIPbTANmzcWpw.png" /></figure><p>It should be like that on the project navigator, then in the project target, you have to click the <strong>+</strong> button into <strong><em>Frameworks, Libraries, and Embedded Content</em></strong> for adding our package to our target, you can see the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kwWV7RJ6Z7bC5QetOwHrw.png" /><figcaption>content</figcaption></figure><p>Then in ViewController’s viewDidAppear, get the LoginViewController from the TodoPackage functionality and present it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fcc2ef652a340a6109390dff5d95300/href">https://medium.com/media/0fcc2ef652a340a6109390dff5d95300/href</a></iframe><p>And run it from simulator or real device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*594tHnYbriFnYwwNh7prZQ.png" /></figure><p>The result is perfect.</p><p>Click the login button and look for the log, I did and this is the output for me</p><blockquote><strong>Todo Todo(id: 1, userId: 1, title: “delectus aut autem”, completed: false)</strong></blockquote><p>So we can easily say that at this point, we created Framework, then created binary frameworks named XCFramework and used it with SwiftPackageManager. You can distribute and use XCFramework with Swift Package Manager in an easy way.</p><h3>What should we do next?</h3><p>We can use Github for the SwiftPackage repository, with this way we can demand our SwiftPackage not in a drag&amp;drop with local way, but remote way, for this article I did not cover it but it would be fun to use the package in this way as usually, we do.</p><p>Thanks for reading the article! I hope you like my article and that it’s helpful and useful. Please feel free to comment about your thoughts, we can discuss it, be safe 🤘🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c03f4b1903d9" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/xcframework-swiftpackagemanager-c03f4b1903d9">XCFramework + SwiftPackageManager</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Cocoapods-Keys]]></title>
            <link>https://medium.com/@itseemrah/introduction-to-cocoapods-keys-840493b98ef1?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/840493b98ef1</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 07:42:07 GMT</pubDate>
            <atom:updated>2020-02-20T07:42:07.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Cocoapods-Keys.</h3><figure><img alt="adsfasd" src="https://cdn-images-1.medium.com/max/1024/1*R1hw4deyv58bdQU-rUEc-Q.png" /><figcaption>Safety and Apple.</figcaption></figure><p>In this article, I will introduce you to <em>Cocoapods-Keys</em> and why we used it in our entertainment applications in <em>IOS</em>. In Inventiv we had to use this plugin because of that security of our keys.</p><p>Assume that you’re using some private keys such as API Keys, API Tokens, Secrets or kinda different private and important data. So it’s obviously that security is so hard to provide because in the app world, all of the platforms can be decrypted. In this section, we will use this plugin to secure our keys without in codebase.The how it works part is in below.</p><blockquote>Key names are stored in ~/.cocoapods/keys/ and key values in the OS X keychain. When you run pod install or pod update, an Objective-C class is created with scrambled versions of the keys, making it difficult to just dump the contents of the decrypted binary and extract the keys. At runtime, the keys are unscrambled for use in your app.</blockquote><p>First of all, you must install cocoapods-keys with this line.</p><pre>$ gem install cocoapods-keys</pre><p>Then let’s start with an example application.</p><p>I’ve started with an application named Flowers. In the project file inited pod &amp; install it without any addition to Podfile.</p><p><em>pod init</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce5bec11dde4da898147117668701cc7/href">https://medium.com/media/ce5bec11dde4da898147117668701cc7/href</a></iframe><p>After install the pod with pod install there’s an key inputs request from terminal as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezwqw9cwm8O3mQm4Fl7gZQ.png" /></figure><p>After you enter your keys open the .xcworkspacefile and open your ViewController .</p><p>Import Keys framework to the top of the file like import Keys .</p><pre><strong>private</strong> <strong>let</strong> keys = FlowersKeys()</pre><pre><strong>private</strong> <strong>func</strong> logKeys(){</pre><pre>     print(keys.flowersPilotApiKey)</pre><pre>     print(keys.flowersProdApiKey)</pre><pre>     print(keys.flowersTestApiKey)</pre><pre>     print(keys.paddleApiKey)</pre><pre>}</pre><p>You can use your keys as you can see in above code block. For safety of the keys you must add Keys folder to the .gitignore file. In repository page it described like that;</p><blockquote>The generated Objective-C classes are stored in the Pods/CocoaPodsKeys directory, so if you&#39;re checking in your <a href="http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control">Pods folder</a>, just add Pods/CocoaPodsKeys to your .gitignore file. CocoaPods-Keys supports integration in Swift or Objective-C projects.</blockquote><p>Add Pods/CocoaPodsKeys to the your .gitignore file.</p><p>If you want to use Keys for multiple targets, you can use it as we did above. You can easily implement &amp; use it Today Extension or various number of different <em>targets</em>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fmeanlimpinggoitered&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fmeanlimpinggoitered-the-matrix-reloaded-congratulations-congrats&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FMeanLimpingGoitered-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="960" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/26e2bd2989a3b3500bff720a9d674d9d/href">https://medium.com/media/26e2bd2989a3b3500bff720a9d674d9d/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840493b98ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to iOS Today Extensions]]></title>
            <link>https://medium.com/multinetinventiv/introduction-to-ios-today-extensions-e387a8df0a29?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/e387a8df0a29</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[today-extension]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 07:39:57 GMT</pubDate>
            <atom:updated>2020-02-20T07:39:57.428Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ll cover the iOS Today Extensions in this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hitSjhTgzHzwM4V7HNBGCg.jpeg" /><figcaption>An image about Apple.</figcaption></figure><p>Today Extensions in iOS provides an extendible feature in the Widget of the iOS. So you can handle this extension how you wish. Let’s start.</p><h3><strong>Creating Extension</strong></h3><p>In File -&gt; New -&gt; Target;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmw6LxPRMYfgkQ1j2gc1iw.png" /><figcaption>Window for Targets</figcaption></figure><p>After you select Today Extension name it <em>SimpleTodayExtension</em> to follow this article with me.</p><p>Well Done. You’ve created your Today Extension.</p><blockquote>If you debug your Today Extension, you have to select Today Extension target before the run otherwise you’ll better to use Application’s target. Bothside you’ll see the changes on codebase &amp; effect on them.</blockquote><p>Run it &amp; In <em>NotificationCenter</em> you’ve to add <em>SimpleTodayExtension</em> as Widget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*a1-8mQQaB-0kHhR4ekSJog.png" /><figcaption>Result of Today Extension.</figcaption></figure><p>This is how your extension will seem at the first run of Application.</p><h3>Main Interface</h3><p>There’s an interface for <em>Today Extension</em>. We’ll change the content of it. If you’re familiar with Storyboard you’ll handle easily. After clicking the <strong><em>MainInterface.storyboard</em></strong> file in <strong><em>Project Structure</em></strong>, you’ll see this screen. This is all the visual playground of Today Extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OD4OMaQkbOiQDexlZ-YarA.png" /><figcaption>MainInterface of Today Extension.</figcaption></figure><p>Now it’s time to select the view of <strong>TodayViewController</strong>. Then in Size Inspector set it’s height to <strong>200</strong>. Then the <strong>Hello World</strong> button will have appeared.</p><p>I am going to delete this UILabel then add a new one manually. The name of the label will be <strong><em>priceStatusLabel</em></strong>. Then set its <strong><em>Horizontally in Container</em></strong> &amp; <strong><em>Vertically in Container</em> </strong>constraint equal to the view of the controller of the extension. And I’ll connect it with the controller of the Today Extension.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39b7bb24989b4d262b885eeef90d5961/href">https://medium.com/media/39b7bb24989b4d262b885eeef90d5961/href</a></iframe><p>Well done if you did all of the steps for it. After you run the App or the Extension center <strong><em>UILabel</em></strong> will be shown at Widget.</p><h3>preferredContentSize</h3><p><em>preferredContentSize</em> variable is specifies the content size of <em>TodayExtension</em>’s <em>UIView</em>. There’s no matter to set width with this variable because the width of the Extension’s View is constantly equal with <em>Device’s width</em>. So for changing <strong>height</strong>, this is the best way.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f4814851797c159e1b0fcef602f7d31/href">https://medium.com/media/6f4814851797c159e1b0fcef602f7d31/href</a></iframe><h3>Make Today Extension Screen Expandable</h3><p>If you wanna your widget expandable you’ve to set it’s expandable</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d1b5ebd0f3f653f57d2a6030be2569d/href">https://medium.com/media/7d1b5ebd0f3f653f57d2a6030be2569d/href</a></iframe><p>You’ve to set <em>extensionContext</em>’s <em>widgetLargetsAvailableDisplayMode</em> to expanded so when you expand it set the <em>expand</em> mode &amp; its height.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*N0ph6lI5fA570FgyYcHQ5Q.png" /><figcaption>We made expandable.</figcaption></figure><p>Yay!. It’s expandable now. You can set your UILayout &amp; Items with control if its <strong>expanded</strong> or <strong>compact</strong>.</p><h3>What is the extensionContext really?</h3><blockquote><strong>extensionContext</strong> is <strong>Optional</strong> variable of the <strong>UIViewController</strong>. When you run Application Target the <strong>extensionContext</strong> will be nil. But other-side when you run the directly extension, it will not be nil.</blockquote><p>For example, when you open a URL or call something is about <em>UIApplication</em>, you cannot call it from Extension because it cannot call the UIApplication object for using. But you can achieve the operations in Extension <em>with</em> <em>extensionContext</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/635aec777b2a4e46a807f5dc69db6924/href">https://medium.com/media/635aec777b2a4e46a807f5dc69db6924/href</a></iframe><h3>widgetPerformUpdate</h3><p>This function is called when the extension wake up with <em>viewDidLoad()</em> and check for if there’s any change in state of the extension.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/811bca60d9e585f81c93b375332bd781/href">https://medium.com/media/811bca60d9e585f81c93b375332bd781/href</a></iframe><p>You better to avoid UI process in the <em>widgetPerformUpdate</em>. Because when app is running and widget is active, it can use main thread in this function. So this can be not good for the app performance. You better do UI things in the <em>viewDidAppear</em> method. But it’s best way to handle background <em>Network Request’s</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a60ebb914af23a05de190915028ad99/href">https://medium.com/media/9a60ebb914af23a05de190915028ad99/href</a></iframe><p>There’s 3 type of update result. If you gonna refresh the content of the Today Extension you must trigger .<em>newData</em> and if there’s no change go with .<em>noData</em> If there’s a error with anything you can use <em>.failed</em></p><h3>Navigate to Application</h3><p>Assume that you’ve a button and after clicking it you’ve to open your application. So let’s create a custom URL Scheme.</p><p>In <em>Application Scheme -&gt; Info -&gt; URL Types</em></p><p>add new URL Scheme like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMFWPFngamCkFxfLojmdMQ.png" /></figure><p>Set your identifier correctly and append <em>.url &amp; </em>set your <em>URL Scheme</em> name to a specific name like your app name. We can share values in same <em>UserDefaults</em> via <em>group-id</em> and also we can send <em>parameters</em> when navigation from <em>Extension</em> to the <em>Application</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d50bf48eda2d04a31cafb936fc9f026f/href">https://medium.com/media/d50bf48eda2d04a31cafb936fc9f026f/href</a></iframe><p>So connect your <em>UIButton</em> and then add <em>#selector </em>for <em>informButtonClicked</em> function.</p><p>In the function, we can share values like amountValue with shared <em>UserDefaults as seen above</em>. This is the one of the good advantages of using <em>TodayExtension</em>. Another advantages of the <em>TodayExtension</em> we can easily use to navigate to the Application with parameters.</p><p>As you see there’s a parameter with named <em>username=simpleUsername. </em>After you clicking the button in TodayExtension, the application will be opened.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c9b2db7654e5c08f9ee11a434e1c9b4/href">https://medium.com/media/5c9b2db7654e5c08f9ee11a434e1c9b4/href</a></iframe><p>You can handle the parameters and change your application’s structure &amp; diagram via these given parameters as like function above.</p><p>You can use the shared group values with using standart functions of <em>UserDefaults </em>as below<em>.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/671df5f49385e7a478342f68ff3bbcad/href">https://medium.com/media/671df5f49385e7a478342f68ff3bbcad/href</a></iframe><p>You can easily manipulate all of the shared data, parameters. So I am happy to describe most basic ways of the <em>TodayExtension</em> 🙌 You can also ask question about the article and <em>TodayExtension</em> structure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e387a8df0a29" width="1" height="1" alt=""><hr><p><a href="https://medium.com/multinetinventiv/introduction-to-ios-today-extensions-e387a8df0a29">Introduction to iOS Today Extensions</a> was originally published in <a href="https://medium.com/multinetinventiv">inventiv</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Firebase App Distribution in iOS]]></title>
            <link>https://medium.com/multinetinventiv/introduction-to-firebase-app-distribution-in-ios-93298d59c658?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/93298d59c658</guid>
            <category><![CDATA[english]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Thu, 02 Jan 2020 20:54:47 GMT</pubDate>
            <atom:updated>2020-01-03T07:06:17.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*bhsZT9dTPWvxj0wj7wrNQA.png" /><figcaption>Firebase App Distribution</figcaption></figure><p>Firebase has a new feature called Firebase App Distribution which provides test the build Beta Tests with Adhoc, analyzes the app with Crashlytics.</p><p>In this post, we will cover the App Distribution without analytic in iOS so let’s start with a basic app. So in Inventiv, we are currently using Firebase App Distribution for Beta testing.</p><p>I started with a basic app called <strong>TutorialApp</strong> like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*JhMOyV41NTCP9MMkDWlbtA.png" /></figure><p>As a result of the app, my bundle identifier is <strong><em>com.multinetinventiv.TutorialApp</em></strong> . We’ll use it further.</p><p>Then add <strong>Firebase</strong> to the app with going <strong>Firebase Console</strong>. You’ve to sign your app with the correct bundle identifier and then download <strong>GoogleService-Info.plist</strong> file onto your Xcode project. After the successful integration of the file, it must be shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPJX4JXBqJQ5D1WcJCnc7Q.png" /><figcaption>Screenshot of the editor.</figcaption></figure><p>After registering the app, we’ve to add <em>Firebase</em> to our codebase with <em>CocoaPods</em>, if you are not comfortable with <em>CocoaPods</em> you can look at many articles in <em>Medium</em> &amp; several blogs.</p><p>Open the terminal to install Firebase.</p><ul><li>Go to your project directory. For my environment, I create my application into my Desktop.</li></ul><p>in Terminal, you can use these steps</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b40a122843f11c599c65b9ba1e59c0aa/href">https://medium.com/media/b40a122843f11c599c65b9ba1e59c0aa/href</a></iframe><p>After the create <strong>Podfile</strong>, open to edit in your text-editor or vim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b36e81d2a80ffd70cd4bdf09df44e47/href">https://medium.com/media/8b36e81d2a80ffd70cd4bdf09df44e47/href</a></iframe><p>After adding <strong>Firebase</strong> pod, the Podfile should like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf9e2dd09bd6b8447627a56bef721b40/href">https://medium.com/media/bf9e2dd09bd6b8447627a56bef721b40/href</a></iframe><p>Save the Podfile then install the pod.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc2176d1e2b2d5a60090e4aa8eb7f122/href">https://medium.com/media/bc2176d1e2b2d5a60090e4aa8eb7f122/href</a></iframe><p>After installing, open the <strong>.xcworkspace</strong> for the configure the <strong>Firebase</strong>.</p><p>Then configure Firebase as documentation guided.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a71b4d185590da93e4530edbcb23236/href">https://medium.com/media/1a71b4d185590da93e4530edbcb23236/href</a></iframe><p>Then look at Firebase App Distribution page at Firebase Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6sWsHTevQnXKu8rU4to1mg.png" /><figcaption>Firebase App Distribution page in Firebase Console.</figcaption></figure><blockquote>The browser languges is currently Turkish but I’ll describe what’s the necessary tabs &amp; how we’ll use it.</blockquote><p>There are currently 3 tabs on the page of App Distribution.</p><ul><li>Distribution</li><li>Invitation Links</li><li>Test Users &amp; Groups</li></ul><p><strong><em>Distribution</em></strong> is currently a place of own app builds for example 1.0.1, 1.0.2, etc. In the distribution place, we’ve to provide the application’s file (iOS App Store Package) as <strong>.ipa </strong>file, because this app package is sent to special beta test users&#39; phones by Firebase.</p><p><strong><em>Invitation Links</em></strong> and <strong><em>Test User</em>&#39;s</strong> place will work when we add a user as a tester and send an invitation to test the application.</p><p>Generating ipa file from the app has require several steps.</p><ul><li>Step 1: Select the testing device of the app target as <strong>Generic iOS Device</strong>.</li><li>Step 2: Click the <strong>Product -&gt; Archive</strong><em> on </em><strong>MenuBar</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8NnmsCpe5ckHMAJzyft-g.png" /><figcaption>Steps</figcaption></figure><p>After this walkthrough, the Organizer window will be opened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SXBU6nnbwOUtOLmw545mtQ.png" /><figcaption>Organizer Page</figcaption></figure><p>We’ve to generate an .ipa file for Firebase App Distribution.</p><p>Click the Distribute App after choose the Ad Hoc option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxivR4ah86ZwZGiTvxWOtw.png" /><figcaption>Method of Distribution Window</figcaption></figure><p>After the preparing archive chooses App Thinning to None and then select Automatically manage signing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AH9j4iEZAD_4i7ZTsK4OVQ.png" /><figcaption>Ad Hoc Distribution Options</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqtnhfOfn-14BdsCac97FA.png" /><figcaption>Signing Options</figcaption></figure><p>Select the export for exporting .ipa file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sG9jYvgVvLYA-G9LQFoh8Q.png" /><figcaption>Review Window</figcaption></figure><p>Go to the export directory and select the .ipa file and drag &amp; drop onto Firebase App Distribution new .ipa section.</p><p>Well done. You’ve uploaded your first build of the app for the Beta Testing. For now, the testers are waiting for the test, let&#39;s add them.</p><p>Add test users with their e-mails. After you add test users you must add release notes. You can add what you wish to add for this release.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m65y0MnsA7Wu5oiFDQ7gjg.png" /><figcaption>Before the Test Release</figcaption></figure><p>Then release it to the testers. <strong>Firebase</strong> has sent e-mails to testers to test the application. There’s some instruction for installing the application. This is showing how Firebase made easy the <strong>Beta Testing</strong> even we are not using better approaches like <strong>Fastlane</strong> etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*_RM81uTtBIALhm-gUR7lfw.jpeg" /><figcaption>Well Done</figcaption></figure><h3>HOUSTON. We’ve had a Problem</h3><p>We’ve had successfully release the app to the testers but did you remember you’ve to register your device for <strong>Ad Hoc</strong> testing (Unique Test Devices) in <strong>App Store Connect</strong> &amp; <strong>TestFlight</strong>. I’ve used my mail address for testers and in my <em>iOS App Developer Account. </em>I have already registered my iPhone device with its unique UUID.</p><p>So what will happen if I use a tester with Firebase App Distribution without registered it into App Developer Account as an Ad Hoc tester?</p><blockquote>Firebase will send invitation mail to tester but the application won’t work because of not registered with a.</blockquote><p>So, add a new unique device to the <strong>App Developer Account</strong>.</p><p>I assume we are an app developer teams, there are new people in <strong>Tester</strong> groups. We have to register them into the system. Let’s begin.</p><p>Login in to your <strong>Apple Developer Account</strong> and select <strong><em>Certificates, Identifiers &amp; Profiles</em></strong>. Then select the <strong>Devices</strong> section on the left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZvQMqxOirXW6RBcGqc1Bw.png" /><figcaption>The list for the registered list.</figcaption></figure><p>Add the <em>Add</em> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3C8SXatRCHagWiEQLeQ0w.png" /><figcaption>Register a New Device Window</figcaption></figure><p>After enter successfully <em>UUID</em> and name continue the process. Then <em>Accept</em> &amp; <em>Register</em> the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnFkln8XR85AbY6ei3_5Og.jpeg" /><figcaption>Well Done</figcaption></figure><p>We’ve just registered the new tester device (<em>iOS, tvOS, watchOS</em>) successfully.</p><p>So the new testers are able to install and test the application via App Distribution. 🙌 🥳</p><p>This is just the beginning with <em>Firebase App Distribution</em>. We’ll discover more efficient use of this distribution system in the next articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93298d59c658" width="1" height="1" alt=""><hr><p><a href="https://medium.com/multinetinventiv/introduction-to-firebase-app-distribution-in-ios-93298d59c658">Introduction to Firebase App Distribution in iOS</a> was originally published in <a href="https://medium.com/multinetinventiv">inventiv</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Trapping Rain Water , Twitter’s Interview Question using UIImageGraphics in Swift]]></title>
            <link>https://medium.com/hackernoon/implementing-trapping-rain-water-twitters-interview-question-using-uiimagegraphics-in-swift-5783885f6d42?source=rss-2b71df906c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/5783885f6d42</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Emrah]]></dc:creator>
            <pubDate>Sat, 24 Jun 2017 16:47:36 GMT</pubDate>
            <atom:updated>2019-05-25T08:35:09.480Z</atom:updated>
            <content:encoded><![CDATA[<p>In this my first article , I will tell you how to implement the<strong> Trapping Rain Water</strong> question which have asked in an <em>interview by </em><a href="https://www.youtube.com/watch?v=UzeL2GcLx3Y"><em>Google</em></a><em> , </em><a href="http://www.businessinsider.com/twitter-job-interview-question-rainfall-walls-2013-12"><em>Twitter</em></a><em> and asked by many companies , </em>with<em> </em>using <strong>Swift</strong> , <strong>UIImageGraphics</strong> .</p><h4>What is the question ?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*UsvWmZOVv-EHvJzJfDWhIQ.png" /><figcaption>Photo is taken from <a href="http://javabypatel.blogspot.com.tr/2016/10/trapping-rain-water-between-towers.html">http://javabypatel.blogspot.com.tr/2016/10/trapping-rain-water-between-towers.html</a></figcaption></figure><p>Firstly , I want to explain the question . There will be given n non-negative integers to represent height of towers and each tower width is just 1 unit . We assume that the rained and here is the question :</p><blockquote>How many unit water fills between the all towers ?</blockquote><h4>How to Solve ?</h4><p>First , I will tell you how to solve it and then I will explain how to implemented it Swift and Core Image.</p><p>We always assume the bar heights is available in a structure (in an array) available . For example tower heights are [ 3 , 0 , 0 , 2 , 0 , 4 ] .</p><p>For each tower we must figure out if there is a tower higher than it in the left side of it and if there is a tower higher than it in the right side of it . If one of the tower is not exist , we assume that the place where the tower was , will not take any water .</p><p>If there are exist 2 tower we can take highest one of left side and highest one of right side then we must take the minimum of both of them . The unit where tower placed , totally will take that minimum number units of water .</p><p>If we subtract the tower height from this minimum number , we will be find out how much water there will be for every tower unit.</p><p>First index as first tower and last index as last tower of Scene will take no water because there are no tower where left of First tower and same way there are no tower where right of Last Tower.</p><h3>Swift Implementation</h3><p>The UIViewController has an <strong><em>UIButton</em></strong> for generate and an <strong><em>UIImageView</em></strong> for represent the image which is processed . Here is the struct for store all tower heights and I will show you that I have divided and represented <strong><em>UIImage</em></strong> as <strong><em>8x8</em></strong> parts . So there will be 8 tower and maximum 8 height unit for each tower for this question.</p><pre>struct WallHeights  {</pre><pre>  var wallHeights : [Int] = [0,0,0,0,0,0,0,0];</pre><pre>}</pre><p>Now , the time for generate tower height randomly .</p><pre>var testWall : WallHeights = WallHeights();</pre><pre>for iterator in 0..&lt;8{</pre><pre>testWall.wallHeights[iterator] = Int(arc4random_uniform(256)) % 8; </pre><pre>}</pre><p>Then , I have started to using UIGraphics functions to start to process image and implemented many functions to find out that can it be filled with water , handle image to generate scenarios and filling water between towers .</p><p>Here is the random scenarios :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*XTHAUGCZOhxIYZOA9hLAJg.gif" /><figcaption>Generating Random Scenarios for this Problem</figcaption></figure><p>The last part of this problem , implement the water fill functions to image . Here is the final state of this problem :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*NvIuJS-EfrUXzwPMU1aI0g.gif" /><figcaption>Filled water into towers</figcaption></figure><p>If the article were helpful and you can star this project on Github.</p><p><a href="https://github.com/eliakorkmaz/Trapping-Rain-Water-with-Swift">eliakorkmaz/Trapping-Rain-Water-with-Swift</a></p><p>If you want to ask question , please comment or message me directly on <a href="https://hackernoon.com/tagged/twitter">Twitter</a> . I will share articles about <a href="https://hackernoon.com/tagged/programming">programming</a> , algorithms and mostly Swift so you can follow me and like the article.</p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5783885f6d42" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/implementing-trapping-rain-water-twitters-interview-question-using-uiimagegraphics-in-swift-5783885f6d42">Implementing Trapping Rain Water , Twitter’s Interview Question using UIImageGraphics in Swift</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>