<?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 Angelo E. Saber on Medium]]></title>
        <description><![CDATA[Stories by Angelo E. Saber on Medium]]></description>
        <link>https://medium.com/@eng.angloesam2010?source=rss-54814a3cd817------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ISi5w4GxkwU7qeqvCzKi_A.jpeg</url>
            <title>Stories by Angelo E. Saber on Medium</title>
            <link>https://medium.com/@eng.angloesam2010?source=rss-54814a3cd817------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:44:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eng.angloesam2010/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[Read local file with Combine]]></title>
            <link>https://medium.com/@eng.angloesam2010/read-local-file-with-combine-50d710bedbd9?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/50d710bedbd9</guid>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Wed, 30 Mar 2022 16:17:04 GMT</pubDate>
            <atom:updated>2022-03-30T16:17:04.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VFX37qhTIaIHgiahsmzvCw.png" /><figcaption>Read local file with Combine</figcaption></figure><p>The Combine framework <strong>provides a declarative Swift API for processing values over time</strong>. These values can represent many kinds of asynchronous events. Combine declares publishers to expose values that can change over time, and subscribers to receive those values from the publishers.</p><p>If you have a local file inside our app and you have to read it .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4da66c6e75fa99cc2098e587dece46a/href">https://medium.com/media/c4da66c6e75fa99cc2098e587dece46a/href</a></iframe><h3>Let start with code to read the file content :</h3><h4><strong><em>At the part 1 , we are reading the file content and convert it from string to data .</em></strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9af2669e03f1c945ba4a0bd6e90d893/href">https://medium.com/media/e9af2669e03f1c945ba4a0bd6e90d893/href</a></iframe><p>1- At line 5 we are creating an extension of Bundle <strong><em>(Bundles organize their contained resources into well-defined subdirectories, and bundle structures vary depending on the platform and the type of the bundle)</em></strong><em> .</em></p><p>2- At line 7 we are declaring a method that have a name <strong><em>readFile method . </em></strong>this<strong><em> </em></strong>method is returning a AnyPublisher&lt;Data, Error&gt; (Any publisher is type-erased struct that conforms the Publisher protocol. Type erasure allows you to hide details about the publisher that you may not want to expose to subscribers ) .</p><p>3- At line 8 by using <strong><em>self.url(/service/forresource: file, withExtension: nil)</em></strong> method will return the content of local file as a <strong><em>String</em></strong> . <strong><em>( Note : the file parameter is the file path inside app)</em></strong></p><p>4- At line 9 we are adding combine publisher to <strong><em>self.url</em></strong> method to use an operate like try map and mapError.</p><p>5- At line 10 , <strong><em>trymap </em></strong>operator is using the return from self.url(/service/forresource: file, withExtension: nil) at line 4 <strong><em>to the convert the content of file from string to Data .</em></strong></p><p>6- from line 11 to line 14 , we are starting to convert file content from <strong>String</strong> of <strong>Data</strong> by using Data(contentsOf: string) method . <strong><em>( Note : string is the file path inside app)</em></strong></p><p>7- At line 16 <strong><em>mapError</em></strong> operator is returning error if any error that will be happen during the convert from string to data .</p><p>8- at line 18 method will return a <strong>eraseToAnyPublisher()( eraseToAnyPublisher() </strong>is <strong>a <em>type erasure</em></strong><em> that </em>returning an instance of AnyPublisher.eraseToAnyPublisher() is using as the last element in a chained pipeline, to simplify the type returned .)</p><h4><strong><em>At the part 2 , Now we need to build our Decodable Struct:</em></strong></h4><p><strong><em>we are creating a Struct of Decodable .Decodable Struct </em></strong>to decode to the content file from JSON Data to Struct<strong><em> .</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a27768d09fa672424e308372d583ac8/href">https://medium.com/media/3a27768d09fa672424e308372d583ac8/href</a></iframe><h4><strong><em>At the part 3 , we are decoding the output from readfile method to generic parameter :</em></strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99f8130ab2b8ebfd45d65eace1b49295/href">https://medium.com/media/99f8130ab2b8ebfd45d65eace1b49295/href</a></iframe><p>1- At line 1 we are creating a method that have name a <strong><em>decodeable . decodeable </em></strong>is a <strong><em>method generic</em></strong> . M<strong><em>ethod Generic</em></strong> is written in angle brackets (<strong>&lt;</strong> placeholder : Type<strong>&gt;</strong>) after the method name but before its parameters . The <strong><em>decodeable</em></strong> function above can take input of Decodable. Decodable is a protocol . When you want to convert JSON data (file content) into a struct, you can conform your object to Decodable .</p><p>2- At line 3 we are calling the readFile method that is returning a AnyPublisher&lt;Data, Error&gt; .</p><p>3- we are using decode(type:decoder:) with a JSONDecoder() to decode data received from a <strong><em>readfile method </em></strong>using the Decodable protocol.</p><p>4- At line 5 <strong><em>mapError</em></strong> operator is returning error if any error that will be happen during the convert from JSON Data to Decodable type .</p><p>5- at line 9 method will return a <strong>eraseToAnyPublisher() .</strong></p><h4><strong>Part 4 : </strong>Implementation of read local file :</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/817576538b1ccf9de92c966e67a4c9eb/href">https://medium.com/media/817576538b1ccf9de92c966e67a4c9eb/href</a></iframe><p>1- at line 1 we are calling Bundle class to subscribe the method decodeable.</p><p>2- a <strong><em>decodeable method</em></strong> is returning a publisher that is publishing to a sink(receiveCompletion:receiveValue:) . sink operater’s receiveValue closure that prints all players to the console. sink operator’s receiveCompletion closure indicates the successful termination of the publisher or display an error if error will happen .</p><h3><strong>Now Full Code for reading local file with Combine</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6c03031718591251b5f5f3ed7b5a137/href">https://medium.com/media/d6c03031718591251b5f5f3ed7b5a137/href</a></iframe><p>Thanks for reading my Article .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50d710bedbd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why property Wrappers are so important in Swift?]]></title>
            <link>https://medium.com/@eng.angloesam2010/why-property-wrappers-are-so-important-in-swift-e18ef209585e?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/e18ef209585e</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 10:05:08 GMT</pubDate>
            <atom:updated>2022-03-17T10:13:36.612Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FU8kz5TXIW9dCPQOJLs%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FU8kz5TXIW9dCPQOJLs%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FU8kz5TXIW9dCPQOJLs%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/79b5f7d658c21357ce95341b6a89ad7b/href">https://medium.com/media/79b5f7d658c21357ce95341b6a89ad7b/href</a></iframe><p>Here we have a struct user</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/105d0001080d5132ba385fbfb64b1d0a/href">https://medium.com/media/105d0001080d5132ba385fbfb64b1d0a/href</a></iframe><p>When we start initializing this struct , in age that is error because the age is -1 , here this is incorrect .</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FXCmFwjt9wPotobw1xn%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FXCmFwjt9wPotobw1xn%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FXCmFwjt9wPotobw1xn%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="363" frameborder="0" scrolling="no"><a href="https://medium.com/media/573a5517c6b67349af0a1acdfd52c71d/href">https://medium.com/media/573a5517c6b67349af0a1acdfd52c71d/href</a></iframe><h3><strong><em>Ok what is the goal for property Wrappers ?</em></strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLmrlNycquCmOPFM6WR%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLmrlNycquCmOPFM6WR%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FLmrlNycquCmOPFM6WR%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/00c30f4c18f2c9f64fee8a8b2a60aa32/href">https://medium.com/media/00c30f4c18f2c9f64fee8a8b2a60aa32/href</a></iframe><p>We want to limit the value or range inside age and the same time I wanna to limit the age between range . here we need to validate the age number and make the age between 1 : 120 years.</p><p>Now we will build <strong><em>property Wrappers 🚀</em></strong></p><p><strong><em>Property Wrappers was build with any type , you can use struct , class and enum to build property wrappers . property Wrappers that attribute provides to swift additional information about declaration and type</em></strong></p><p>to transform the struct to <strong><em>Property Wrappers by add </em></strong>@property Wrappers above struct automatically the struct will be @property Wrappers .</p><p><strong><em>this @propertyWrapper is required to build a property Wrappers 💪</em></strong></p><p>in this case we will use struct age to wrapped the value</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6793a10cab1ebe5ab6019cb0fefe0aa/href">https://medium.com/media/c6793a10cab1ebe5ab6019cb0fefe0aa/href</a></iframe><p>but we need add some code in user Struct add the keyword Age to change type of age from Int <strong><em>Age property Wrappers but add @ before the name .</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b95bb94058a0b56d42c88d4ce9399d/href">https://medium.com/media/24b95bb94058a0b56d42c88d4ce9399d/href</a></iframe><p><strong>how it is work ?</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F10yIEN8cMn4i9W%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F10yIEN8cMn4i9W%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F10yIEN8cMn4i9W%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/73f4fefc82df2a7aaa41008223d18138/href">https://medium.com/media/73f4fefc82df2a7aaa41008223d18138/href</a></iframe><p><strong>@Age var age : Int = 0 is evaluate with @Age (wrappedValue : 0) var age</strong></p><p>if you are now you call and create a copy of struct</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64cd45654d83659b74108863b2e85fe0/href">https://medium.com/media/64cd45654d83659b74108863b2e85fe0/href</a></iframe><p>in the state one will be zero and in state two will be 120</p><p>Now Tell Me Why</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3cXmze4Y8igXdnkc3U%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3cXmze4Y8igXdnkc3U%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZDhheTM2cXc0dTcxdXd5eHd4Y3R0Nmd5YXhvZm45ejNkNGxyMWk0biZlcD12MV9naWZzX2dpZklkJmN0PWc%2F3cXmze4Y8igXdnkc3U%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc5091c083842830c92387c92334b771/href">https://medium.com/media/dc5091c083842830c92387c92334b771/href</a></iframe><p>because we are setting a limit to age start from 1 to 120</p><h4>Are you can use property Wrappers as a computed property ?</h4><p>yes , you can do it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48ee6a85f44da3a70996d90076a0bd9e/href">https://medium.com/media/48ee6a85f44da3a70996d90076a0bd9e/href</a></iframe><p>the wrappedValue will be trigger the value from age .</p><p><strong>Conclusion</strong></p><blockquote><strong><em>Property Wrappers was build with any type , you can use struct , class and enum to build property wrappers . property Wrappers that attribute provides to swift additional information about declaration and type</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e18ef209585e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to used Subscriber with different way ?]]></title>
            <link>https://medium.com/@eng.angloesam2010/how-to-used-subscriber-with-different-way-902d891ebcad?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/902d891ebcad</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 07:51:49 GMT</pubDate>
            <atom:updated>2022-03-17T04:53:45.896Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to use Subscriber?</h3><h3><em>Subscriber</em></h3><p><em>is a protocol that defines the requirements for a type to be able to receive input from a publisher.</em></p><p>Now we understand Subscriber is protocol to <em>receive</em> values from publisher , combine framework was support a many of way to <em>receive</em> this vales .</p><h4><em>1- </em>Subscribing with sink(receiveValue:)</h4><p>It is operator , you can use it to receive values from publisher . you can create a subscriber with sink like down example .</p><p>In this example, a <a href="https://developer.apple.com/documentation/swift/range">Range</a> publisher publishes integers to a sink(receiveValue:) operator’s receiveValue closure that prints them to the console:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a78946ca6e8f12ca8c4b81cfa179993b/href">https://medium.com/media/a78946ca6e8f12ca8c4b81cfa179993b/href</a></iframe><p>The sink operator will continue to receive as many values as the publisher emit . this is known as <strong><em>unlimited demand</em></strong>. And although you ignored them in</p><h4>2 - <strong>Subscribing with </strong>sink(receiveCompletion:receiveValue:)</h4><p>sink operator it do the same think before receive values from publisher but here actually provides two closures:</p><p>1- receiveValue closure: to handle receiving values</p><p>2- receiveCompletion closure : handle receiving a completion event (a success or a failure) . let look for next example to understand how it is work</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cfdc030708b3a4c5c6b7d7aed767135/href">https://medium.com/media/9cfdc030708b3a4c5c6b7d7aed767135/href</a></iframe><p>look for output . at line 21 the subscriber will be start from receiveValue closures to handle receiving values , when finish from receiving values the subscriber will be go to completion event closures at line 4 to handle the state for data if the data is complete or no , or error was happen .</p><p>There are two possible cases:</p><ul><li>.finished — The publisher is telling the subscriber that there will be no more values forthcoming because it has finished producing values <a href="https://www.apeth.com/UnderstandingCombine/start/startcompletions.html#SECcompletion">in good order</a>. For example, a data task publisher sends a .finished completion after it has done whatever networking we asked it to do.</li><li>.failure — The publisher is telling the subscriber that there will =he nature of that failure is expressed as an Error object which is this enum case’s associated value</li></ul><p><strong>3- Subscribing with assign(to:on:)</strong></p><p>Assign is a subscriber that’s designed to apply data from a publisher into a property, updating every time that property whenever it receives data from publisher .</p><blockquote>Use the <a href="https://developer.apple.com/documentation/combine/publisher/assign(to:on:)">assign(to:on:)</a> subscriber when you want to set a given property each time a publisher produces a value.assign a subscriber is take two , the first parameter is a property, the second parameter is an object .</blockquote><p>here example to understand more about assign subscriber</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e711cd1ca92dbd77d2f29bea7129ca33/href">https://medium.com/media/e711cd1ca92dbd77d2f29bea7129ca33/href</a></iframe><p>From the top:</p><p>1. Define a class with a property that has a didSet property observer that prints the new value.</p><p>2. Create an instance of that class (ExmpleObject at line 10).</p><p>3. Create a publisher from an array of strings (at line 11).</p><p>4. Subscribe to the publisher, assigning each value received to the value property of the object.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FBemKqR9RDK4V2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FBemKqR9RDK4V2%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FBemKqR9RDK4V2%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="260" frameborder="0" scrolling="no"><a href="https://medium.com/media/97cdbbf58f4deeea929bcb131b34d10a/href">https://medium.com/media/97cdbbf58f4deeea929bcb131b34d10a/href</a></iframe><p>Note:</p><p>The <a href="https://developer.apple.com/documentation/combine/subscribers/assign">Subscribers.Assign</a> instance created by this operator maintains a strong reference to object, and sets it to nil when the upstream publisher completes (either normally or with an error).</p><p>you can preview article to understand Combine :</p><p><a href="https://medium.com/@eng.angloesam2010/good-start-with-combine-part-1-eef2f1bed141">1- Good Start with Combine (Part 1)</a></p><p><a href="https://medium.com/@eng.angloesam2010/good-start-with-combine-part-2-a259e6183fec">2- Good Start with Combine (Part 2)</a></p><p><a href="https://medium.com/@eng.angloesam2010/how-it-works-combine-pipeline-c27f1427e3e3">3- How it works Combine pipeline?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=902d891ebcad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How it works Combine pipeline?]]></title>
            <link>https://medium.com/@eng.angloesam2010/how-it-works-combine-pipeline-c27f1427e3e3?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27f1427e3e3</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[iosprogrammatically]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Sun, 13 Mar 2022 06:29:45 GMT</pubDate>
            <atom:updated>2022-03-13T06:29:45.039Z</atom:updated>
            <content:encoded><![CDATA[<p>A Combine pipeline is built from a publisher, some operators, and a subscriber. Publisher response to send values to subscriber and subscriber receive values<em> </em>Publisher .</p><p>Now publisher is send values and subscriber is receive values but how this connection is happen , and when publisher send value to subscriber .</p><h3>When publisher send value to subscriber<strong>?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1A98ggjvV0H5bsYGqRejlg.png" /><figcaption>Subscription</figcaption></figure><p>The connection between the publisher and the subscriber is the subscription . subscription is a protocol . The publisher sends a subscription to the subscriber. The subscriber can use a subscription to make a request from the publisher for a definite or indefinite number of values. It is like a bridge and postman between subscriber to notify publisher to get values .</p><p><strong>Understanding what’s going on</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KG3evgtNepCHr-Mkf0k5Ew.png" /></figure><p>Here the complete process for Subscription :</p><ol><li>The subscriber subscribes to the publisher.</li></ol><p>2. The publisher creates a subscription and gives it to the subscriber.</p><p>3. The subscriber requests values.</p><p>4. The publisher sends values.</p><p>5. The publisher sends a completion.</p><h3>More details</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGNPr_2JROXktOr4rPWP5Q.png" /></figure><p>1- You call subscribe(_:) on publisher , passing your subscriber.</p><p>2- The publisher sends a subscription to the subscriber.</p><p><strong><em>3- The subscriber can then use this subscription to make a request from the publisher for a definite or indefinite number of values.</em></strong></p><p>4- After that, the publisher is free to send values to the Subscriber.</p><p>5- It might send the full number of requested values, but it might also send fewer.</p><p>5- If the publisher is finite, it will eventually return the completion event or possibly an error.</p><h3><strong>Publisher protocol</strong></h3><p>Take a look at the Publisher protocol and one of its most important extensions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74740c63d459bcb625945b162063d682/href">https://medium.com/media/74740c63d459bcb625945b162063d682/href</a></iframe><p><em>Here’s a closer look:</em></p><p><em>1. The type of values that the publisher can produce.</em></p><p><em>2. The type of error a publisher may produce, or Never if the publisher is</em></p><p><em>guaranteed to not produce an error.</em></p><p><em>3. A subscriber calls subscribe(_:) on a publisher to attach to it.</em></p><p><em>4. The implementation of subscribe(_:) will call receive(subscriber:) to</em></p><p><em>attach the subscriber to the publisher, i.e., create a subscription.</em></p><h3><strong>Subscriber protocol</strong></h3><p>The associated types are the publisher’s interface that a subscriber must match in order to create a subscription. Now, look at the Subscriber protocol:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c09c7bbad610eae9c0b153b52dc1b7e9/href">https://medium.com/media/c09c7bbad610eae9c0b153b52dc1b7e9/href</a></iframe><p><em>Here’s a closer look:</em></p><p>1. The type of values a subscriber can receive.</p><p>2. The type of error a subscriber can receive; or Never if the subscriber won’t receive an error.</p><p>3. The publisher calls receive(subscription:) on the subscriber to give it the subscription.</p><p>4. The publisher calls receive(_:) on the subscriber to send it a new value that it just published.</p><p>5. The publisher calls receive(completion:) on the subscriber to tell it that it has finished producing values, either normally or due to an error.</p><h3><strong>Subscription protocol</strong></h3><p><strong>The connection between the publisher and the subscriber is the subscription. Here’s the Subscription protocol:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30ef82abb58480c6858f446a6fcc0691/href">https://medium.com/media/30ef82abb58480c6858f446a6fcc0691/href</a></iframe><p>The subscriber calls request(_:) to indicate it is willing to receive more values, up to a max number or unlimited.</p><p>In Subscriber, notice that receive(_:) returns a Demand. Even though subscription.request(_:) sets the initial max number of values a subscriber is willing to receive, you can adjust that max each time a new value is received.</p><blockquote>Conclusion</blockquote><blockquote>The connection between the publisher and the subscriber is the subscription . subscription is a protocol . The publisher sends a subscription to the subscriber. The subscriber can use a subscription to make a request from the publisher for a definite or indefinite number of values. It is like a bridge and postman between subscriber to notify publisher to get values .</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27f1427e3e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Good Start with Combine (Part 2)]]></title>
            <link>https://medium.com/@eng.angloesam2010/good-start-with-combine-part-2-a259e6183fec?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/a259e6183fec</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[iosprogrammatically]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[combine]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Tue, 08 Mar 2022 16:47:41 GMT</pubDate>
            <atom:updated>2022-03-08T16:47:41.643Z</atom:updated>
            <content:encoded><![CDATA[<p>from preview <a href="https://medium.com/@eng.angloesam2010/good-start-with-combine-part-1-eef2f1bed141">article</a> we are knowing that Combine is implements a Functional Reactive Programming (FRP) paradigm that’s similar to that of <a href="http://reactivex.io/">Rx</a> which is implemented by <a href="https://github.com/ReactiveX/RxSwift">RxSwift</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5WS2Jkz-4MIGSb2A0HL6w.gif" /></figure><p>look for image , Simple Combine is a flow of data from one function to the other automatically that function do task and return a value .at the end of process we have an output that will notify to another object like display data to mobile or send data to server .</p><h4>Combine is consisting three part publishers, operators and subscribers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dbMl1xBcrMUWVmYJNPw2Fw.gif" /></figure><h3>from this image we will understand every point :</h3><p>Publisher : At the heart of Combine is the Publisher protocol . the main role is transmits a sequence of values over time to subscribers . Publishers have Operators to act on the values received from upstream publishers and republish them. Publishers only emit values . publisher is an object that sends values to its subscribers over time .</p><p>Subscribers : Subscribers is a protocol, At the end of a publishers , Subscribers can receive any values , a <a href="https://developer.apple.com/documentation/combine/subscriber">Subscriber</a> acts on elements as it receives them . Publishers only emit values when explicitly requested to do so by subscribers.</p><p><strong>Here Code to start understanding How It is work :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f66ce1d276bb2a2f6d8732b52e5acec3/href">https://medium.com/media/f66ce1d276bb2a2f6d8732b52e5acec3/href</a></iframe><p>output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwGZI7aGY7Fw1iAzucZ1Xg.png" /></figure><p>The Combine framework adds a publisher property to Array. We can use this property to turn an array of values into a publisher . Now we have a two operation , first one is map , that map operator multiple elements of the array in number 2 , at line 4 second operator is filter operator that operator will bet get out from any element greater than 2 from array .</p><p>at line 5 , You can subscribe to a publisher using the sink(receiveCompletion:receiveValue:) method. This method creates a subscriber that is subscribed to the publisher that the method was called on. It&#39;s important to note that publishers only publish values when they have subscribers. Calling sink(receiveCompletion:receiveValue:) on a publisher creates a subscriber immediately and enables the publisher to begin streaming values.</p><blockquote>Conclusion</blockquote><blockquote>Publisher : At the heart of Combine is the Publisher protocol . the main role is transmits a sequence of values over time to subscribers .</blockquote><blockquote>Subscribers : Subscribers is a protocol, At the end of a publishers , Subscribers can receive any values</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a259e6183fec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Good Start with Combine (Part 1)]]></title>
            <link>https://medium.com/@eng.angloesam2010/good-start-with-combine-part-1-eef2f1bed141?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/eef2f1bed141</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Mon, 07 Mar 2022 08:04:22 GMT</pubDate>
            <atom:updated>2022-03-07T08:04:22.541Z</atom:updated>
            <content:encoded><![CDATA[<p>The Combine framework, It implements a Functional Reactive Programming (FRP) paradigm that’s similar to that of <a href="http://reactivex.io/">Rx</a> which is implemented by <a href="https://github.com/ReactiveX/RxSwift">RxSwift</a>,</p><h3>What is Functional Reactive programming ?</h3><p>Functional Reactive programming is a combination of functional and reactive paradigms. your code is written in a way where data flows from one place to the other automatically. It uses the building blocks of Functional Programming .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LOvyc7mRGHGLgcQCyfqzxA.jpeg" /><figcaption>Functional Reactive programming</figcaption></figure><h3>What is Functional programming :</h3><p><strong>Functional programming</strong> is a <a href="https://en.wikipedia.org/wiki/Programming_paradigm">programming paradigm</a> where programs are constructed by <a href="https://en.wikipedia.org/wiki/Function_application">applying</a> and <a href="https://en.wikipedia.org/wiki/Function_composition_(computer_science)">composing</a> <a href="https://en.wikipedia.org/wiki/Function_(computer_science)">functions</a>.</p><p>for example if we have an array of data , that will be input for many of function , every function will be modify or filter data , but from one place to the other automatically and generate a new data .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwQ4MdZwRyUxqaT-wVn7zA.jpeg" /></figure><h3>Characteristics of Functional Programming</h3><ul><li>Every part of functional programming is method focuses on results, not the process .</li><li>Emphasis is on what is to be computed</li><li>Data is <strong><em>immutable (if we have array of data , the original array will’t modified or deleted , but generate a new data for modification or deleted so that the data is immutable)</em></strong></li><li>Functional programming Decompose the problem into ‘functions</li><li>It is built on the concept of mathematical functions which uses conditional expressions and recursion to do perform the calculation</li><li>It does not support iteration like loop statements and conditional statements like If-Else .</li></ul><h3>What is Reactive Programming ?</h3><p>Reactive programming is the practice of programming with asynchronous data streams or event streams. An <strong>event stream</strong> can be anything like keyboard inputs, button taps, gestures, GPS location updates, accelerometer, and iBeacon. You can listen to a stream and react to it accordingly.</p><p>First, let’s take a look at what it means to write reactive code , Let’s start with a simple example: a switch and a light bulb. As you flick the switch, the light bulb turns on and off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*r5U1eDUZcScoreRL1WFzpA.png" /></figure><p>The two components are coupled. Usually you don’t give much thought to <strong><em>how they are coupled, but let’s dig deeper.</em></strong></p><p>One approach is to have the switch modify the state of the bulb. In this case, the switch is <strong>proactive</strong>, pushing new states to the bulb; whereas the bulb is <strong>passive</strong>, simply receiving commands to change its state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*oqVYGaHlfFDSpX3mimew8A.png" /></figure><p>We’ll represent this relationship by putting the arrow on the switch — that is, the one connecting the two components is the switch, not the bulb.</p><p>The other way to couple these components would be to have the bulb listen to the state of the switch then modify itself accordingly. In this model, the bulb is <strong>reactive</strong>, changing its state based on the switch’s state; whereas the switch is <strong>observable</strong>, in that others can observe its state changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*lx1gT_Yvx-t8grntJd3bIg.png" /></figure><p>Real example with swift Code :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d46c79131be955aa257bd365fbf62a7b/href">https://medium.com/media/d46c79131be955aa257bd365fbf62a7b/href</a></iframe><blockquote>Understanding flatMap</blockquote><blockquote>The slightly more complicated sibling of map is called flatMap. You use this flavor of map when you have a sequence of sequences, for instance, an array of arrays, that you want to &quot;flatten&quot;. An example of this is removing nested arrays so you end up with one big array. <strong>.flatMap()</strong> basically just like .map(), except it filters out any nil values.</blockquote><p>it’s two dimensional array , we will do a many of <strong>event</strong> in this two dimensional array . first flatMap method will be return all element from two dimensional array as one sequence . second we multiply each element from new array (that generate from flatMap) in number 2 and return a new array .</p><blockquote>we do a many of <strong>event stream with map and flat-map to </strong>react a new array</blockquote><h3>Conclusion</h3><blockquote>Functional Reactive programming is a combination of functional and reactive paradigms.</blockquote><blockquote>Functional programming is a programming paradigm where programs are constructed by applying and composing functions.</blockquote><blockquote>Reactive programming is the practice of programming with asynchronous data streams or event streams</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eef2f1bed141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[simple way for Localization in SwiftUI]]></title>
            <link>https://medium.com/@eng.angloesam2010/simple-way-for-localization-in-swiftui-4134e21a50ca?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/4134e21a50ca</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios-apps]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 23:32:52 GMT</pubDate>
            <atom:updated>2022-03-30T16:03:37.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple way for Localization in SwiftUI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rp9y7NDEy00j6tfwQ1Gziw.png" /><figcaption>Localization in SwiftUI</figcaption></figure><p>SwiftUI makes localization straightforward. But you need to perform a few steps to get it set up :</p><p>1- Go to the Info page of your project and select the project name .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jbG6vJ_kOYooUaHOCkLYUQ.png" /></figure><p>2- On the Info page, expand the Localizations section and click the plus sign (+) below it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1x9dpeNLTKEDhDyrTklTtw.png" /></figure><p>3- Select the language that you want to localize to it . For this example, I select Arabic language .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vg-8ANR0pJBKHOpiCxUU7w.png" /></figure><p>3- In Xcode, choose File ⇒ New ⇒ File. (or press command + N)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JPsNaz_mMufqDr9HCtphEA.png" /></figure><p>4- Select Strings File and click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1h9NqOYMNLeb1iA2XkhK5A.png" /></figure><p>5- Set the file name “ Localizable.strings” . The file should appear in your project .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3JJbfkKOo96lq5XFnk6BA.png" /></figure><p>6- In the File Inspector window, click the Localize button in right side menu .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ite-uuN9k1yIEwgyBJZk7w.png" /></figure><p>7- In the in right side part . you have select a localization and see an additional item named Arabic (as you are select).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EksYUMhi2XAm-3gx_yGoLA.png" /></figure><p>8- You have to select Arabic Language in Localization part (in right side part) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5FPvOEaNCaWeBGhctJCJg.png" /></figure><p>9- Expand the Localizable.strings item in your project to reveal the two files Localizable.strings (English) and Localizable.strings (Arabic).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BIsnz3sl4m51gKSGxEPsmw.png" /></figure><p>10- Add the following strings to the Localizable.strings (English) file:</p><p>“Hello, Angelo!” = “Hello, Angelo!”;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEGhZhf2rTnSd0Oyn9ZJ_A.png" /></figure><p>11- Add the following strings to the Localizable.strings (Arabic ) file:<br>“Hello, Angelo!” = “!اهلا انجلو ”;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HsXNhlRtCgQJ4HjEIz9GgA.png" /></figure><p>When you run the app on an iOS device with the language , it will automatically display the Text view in English .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70a26720a643256b043f41a6ccd7da08/href">https://medium.com/media/70a26720a643256b043f41a6ccd7da08/href</a></iframe><p>To test your application in the preview canvas, use can add environment() modifier on the ContentView with add the <strong><em>“ar”</em></strong> identifier:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed0ce220395ce2e0df2bf266672376b1/href">https://medium.com/media/ed0ce220395ce2e0df2bf266672376b1/href</a></iframe><p>This is output when test it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCtCF4ZcXUcpdTTNwpsuGg.png" /></figure><blockquote><em>Quotes “ Before software can be reusable it first has to be usable. “</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4134e21a50ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fantastic Composing Gestures in SwiftUI]]></title>
            <link>https://medium.com/@eng.angloesam2010/fantastic-composing-gestures-in-swiftui-5effb455bdac?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/5effb455bdac</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 20:56:41 GMT</pubDate>
            <atom:updated>2022-02-28T20:56:41.490Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qvhbKZD_6Z4xLRWLBkmyXw.png" /></figure><blockquote><strong>“you need to use multiple gesture recognizers in the same view”</strong></blockquote><p>It is also possible to combine multiple gestures and apply them to a view because when you add multiple gestures to your app’s view hierarchy, you need to decide how the gestures interact with each other. so that Gestures can be combined so that they are detected simultaneously, in sequence or exclusively.</p><p>Simultaneously Gestures: both gestures must be detected at the same time for the corresponding action to be performed.</p><p>Sequential Gestures : the first gestures must be completed before the second gesture will be detected.</p><p>Exclusive gestures : is a combination of two gestures but with only one gesture that will work by specifying which one has the highest priority.</p><blockquote><strong>Gestures are composed using the simultaneously(), sequenced() and exclusively() modifiers</strong></blockquote><h4>Simultaneously Gestures:</h4><blockquote>we apply Simultaneously<em> to Gesture</em> with add <strong>simultaneously<em> modifiers .</em></strong></blockquote><p>For example, composes a simultaneous gesture consisting of a long press and a drag:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLBK76BC1YMY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLBK76BC1YMY&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/121a7c83787b3bae2585471289fb10bd/href">https://medium.com/media/121a7c83787b3bae2585471289fb10bd/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79916435e0483dcebe3d80a28e1bec2d/href">https://medium.com/media/79916435e0483dcebe3d80a28e1bec2d/href</a></iframe><p>at line 16 we add Gesture modifier and apply a LongPressGesture Recognizer with update callback action to detect if the user press long time for a image or no ,with using simultaneously modifier at line 21 , I will’t wait for LongPressGesture() recognizer to finish , I can move the image with DragGesture() recognizer and update the value for a image with offset .</p><h3>Sequential Gesture :</h3><p>Sequence gesture allows you to combine gestures but only allow one gesture to complete before allowing the following gesture to be triggered.</p><blockquote>we apply Sequential<em> to Gesture</em> with add <strong><em>sequenced modifiers .</em></strong></blockquote><p>In our example a sequential gesture is configured which requires the long press gesture to be completed before the drag operation can begin. When executed, the user will perform a long press on the image until it turns green, at which point the drag gesture can be used to move the image around the screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40c16cb5d870d823d4ac8a2ffd1bfcd6/href">https://medium.com/media/40c16cb5d870d823d4ac8a2ffd1bfcd6/href</a></iframe><p>at line 15 LongPressGesture recognizer will be apply an onEnd action and change the value <strong><em>dragEnable property wrapper </em></strong>from false to true after 10 second .</p><p>at line 19 with using sequenced modifier , we will add a second recognizer <strong><em>DragGesture recognizer </em></strong>so we will apply update callback action at line 20.</p><p>at line 25 <strong><em>state parameter will return value from drag?.translation </em></strong>where where user is moving his finger and update the offset GestureState property at runtime .</p><p>at line 30 we will change the value <strong><em>dragEnable property wrapper </em></strong>from true to false again .</p><h4>Exclusively Gestures:</h4><blockquote><strong>A gesture that consists of two gestures where only one of them can succeed. Apple Documentation</strong></blockquote><p>Here our example using Exclusively, With the code below, Exclusive Gesture of Rotation is placed on Tap Gesture. Here, you you will place more emphasis on Rotation Gesture by placing it in Exclusive. And you will be able to choose to Tap Once or Rotate. However, if you will perform both gesture at the same time, it will favor Rotate over Tap Once because Rotate is placed under Exclusive Gesture.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVix4hJx5c_A&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVix4hJx5c_A&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/83809350d3690e64fb1c2b4ac56ad5e5/href">https://medium.com/media/83809350d3690e64fb1c2b4ac56ad5e5/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7f18c8c56604bd87e6e402233e37e7d/href">https://medium.com/media/b7f18c8c56604bd87e6e402233e37e7d/href</a></iframe><p>at line 17 we will start with TapGesture Gesture when click one time .</p><p>at line 19<strong><em> self.isDay.toggle() </em></strong>this method make the<strong><em> </em></strong>value for isDay property will be change from false boolean to true boolean and this will affect in change image at line 11 .</p><p>at line 11 the value for image will be sun if true and it will be moon if false .</p><p>at line 21 with using exclusively modifier , the second recognizer will be RotationGesture that gesture will rotate the image , and return angle from on change callback action at line 25 .</p><h3>Conclusion</h3><blockquote>Simultaneously Gestures: both gestures must be detected at the same time for the corresponding action to be performed.</blockquote><blockquote>Sequential Gestures : the first gestures must be completed before the second gesture will be detected.</blockquote><blockquote>Exclusive gestures : is a combination of two gestures but with only one gesture that will work by specifying which one has the highest priority.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5effb455bdac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The updating Callback Action with DragGesture]]></title>
            <link>https://medium.com/@eng.angloesam2010/the-updating-callback-action-with-draggesture-5614c12d4746?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/5614c12d4746</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 12:30:59 GMT</pubDate>
            <atom:updated>2022-02-28T12:30:59.778Z</atom:updated>
            <content:encoded><![CDATA[<p>from <a href="https://medium.com/@eng.angloesam2010/magic-modifier-in-swiftui-gestures-1c0980c4334b">article</a> Magic Modifier in SwiftUI (Gestures) we are knowing a Gesture is Protocol and it has few extension function that provide functionality for performing gestures related operations . one of these function is the update Callback action .</p><h3>What is the updating Callback Action ?</h3><h4>Declaration</h4><pre>func updating&lt;State&gt;(_ state: <a href="https://developer.apple.com/documentation/swiftui/gesturestate">GestureState</a>&lt;State&gt;, body: @escaping (Self.Value, inout State, inout <a href="https://developer.apple.com/documentation/swiftui/transaction">Transaction</a>) -&gt; <a href="https://developer.apple.com/documentation/swift/void">Void</a>) -&gt; <a href="https://developer.apple.com/documentation/swiftui/gesturestategesture">GestureStateGesture</a>&lt;Self, State&gt;</pre><p>It is action / function like onChanged but is updates the provided gesture state property as the gesture’s value changes</p><p>The updating callback action it works with a special property wrapper named @GestureState. GestureState is designed exclusively for use with gestures. @GestureState properties automatically reset to the original state when the gesture ends.</p><h4>Here Example to understand :</h4><p>The following example adds a DragGesture to an Image view and then uses the updating callback to keep a @GestureState property updated with the current translation value. An offset() modifier is applied to the Image view using the @GestureState offset property. This has the effect of making the Image view follow the drag gesture as it moves across the screen.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMhICdw-X0IA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMhICdw-X0IA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMhICdw-X0IA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/644ac70b0f54af34d69e9646cb1586bb/href">https://medium.com/media/644ac70b0f54af34d69e9646cb1586bb/href</a></iframe><h3>Here Code :</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21842853cabcb82b72a93c6db5cc7b9d/href">https://medium.com/media/21842853cabcb82b72a93c6db5cc7b9d/href</a></iframe><p>Typically, a drag gesture updating callback will extract the translation value from the DragGesture.Value object and assign it to a @GestureState property and will typically resemble the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFJAJMHrXYr2ENVSkyPmsQ.jpeg" /></figure><blockquote><em>Conclusion</em></blockquote><blockquote>The updating callback action it works with a special property wrapper named @GestureState. GestureState is designed exclusively for use with gestures. @GestureState properties automatically reset to the original state when the gesture ends.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5614c12d4746" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magic Modifier in SwiftUI (Gestures)]]></title>
            <link>https://medium.com/@eng.angloesam2010/magic-modifier-in-swiftui-gestures-1c0980c4334b?source=rss-54814a3cd817------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c0980c4334b</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[gestures]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Angelo E. Saber]]></dc:creator>
            <pubDate>Sun, 27 Feb 2022 08:29:24 GMT</pubDate>
            <atom:updated>2022-02-27T09:18:31.749Z</atom:updated>
            <content:encoded><![CDATA[<p>(Part 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snIcIdUvEJ7bzbzGZybyBg.png" /></figure><h3>What is Gestures ?</h3><p>Gestures is to describe an interaction between the touch screen and the user which can be detected and used to trigger an event in the app.</p><h3>Basic of Gestures :</h3><p>Gestures performed within the bounds of a view can be detected by adding a gesture recognizer to that view. SwiftUI provides recognizers for tap, long press, rotation, magnification (pinch) and drag gestures.<br>A gesture recognizer is added to a view using the gesture() modifier, <br>a recognizer will include one or more action callbacks containing the code to be executed when a matching gesture is detected on the view.</p><p>For example If you need to count how many times you touch an image , you will use Gestures modifier , with a special recognizer to detect the touch on the screen (may be user drag image , press for a long time on the image , you need only to detect the touch on the image so that you can add a recognizer to discover any type of interaction ).</p><h4>Here Example :</h4><p>Example when the user presses on an image and releases his finger , the number of counter will be displayed in debug console .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f52bfb2bbaaae2f520228a2465a99cfc/href">https://medium.com/media/f52bfb2bbaaae2f520228a2465a99cfc/href</a></iframe><p>At line 6 we apply Gesture Modifier for an image to detect the press finger . At line 8 add a recognizer TapGesture() , this will detect the press on the image, after finger release , the call back function will be print “ How many times for touching in an image “ .</p><h3>Are Gesture is Protocol and What is call back function in recognizer?</h3><p>Yes , Gesture is a protocol . Gesture protocol has few extension function that provide functionality for performing gestures related operations:</p><ul><li><a href="https://developer.apple.com/documentation/swiftui/gesture/updating(_:body:)">updating(_:body:)</a> : Updates the provided gesture state property as the gesture’s value changes.</li><li><a href="https://developer.apple.com/documentation/swiftui/gesture/onchanged(_:)">onChanged(_:)</a> : Adds an action to perform when the gesture’s value changes. Many of the gesture recognizers (except for TapGesture) also allow the addition of an onChange action callback. The onChange callback will be called when the gesture is first recognized, and each time the underlying values of the gesture change, up until the point that the gesture ends.</li><li><a href="https://developer.apple.com/documentation/swiftui/gesture/onended(_:)">onEnded(_:)</a> : Adds an action to perform when the gesture ends. the onEnded action closure was used to detect when a gesture completes.</li></ul><blockquote>Conclusion</blockquote><blockquote>from our example we discover that Gesture is modifier and you have to add recognizer to detect the action , a recognizer will include one or more action callbacks containing the code to be executed when a matching gesture is detected on the view.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c0980c4334b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>