<?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 Gorkem Gur on Medium]]></title>
        <description><![CDATA[Stories by Gorkem Gur on Medium]]></description>
        <link>https://medium.com/@gorkemmgur?source=rss-7d20cabf8527------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CaoCEeOPau8KZak2HtQPQg.jpeg</url>
            <title>Stories by Gorkem Gur on Medium</title>
            <link>https://medium.com/@gorkemmgur?source=rss-7d20cabf8527------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:22:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gorkemmgur/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[CollectionView İle Compositional Layout Kullanımı]]></title>
            <link>https://medium.com/appcent/collectionview-i%CC%87le-compositional-layout-kullan%C4%B1m%C4%B1-7cfdb2b19911?source=rss-7d20cabf8527------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cfdb2b19911</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[collectionview]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Gorkem Gur]]></dc:creator>
            <pubDate>Tue, 20 Feb 2024 16:28:43 GMT</pubDate>
            <atom:updated>2024-02-20T16:28:43.626Z</atom:updated>
            <content:encoded><![CDATA[<h3>Compositional Layout Nedir ?</h3><p>Apple tarafından WWDC19 ile kullanımımıza sunulmuştur, karmaşık UI öğelerini bir arada kullanmak için oldukça güçlü bir API’dir.</p><h3>Compositional Layout’u Neden Kullanmalıyız ?</h3><p>Yukarıda da bahsettiğimiz gibi eğer karmaşık bir UI yapısı kurmamız gerekiyorsa ya da dynamic olarak değişkenlik gösteren bir sayfa yapımız varsa örneğin backend servisi tarafından bize dönen response içerisinde AppStore gibi en üstte slider hemen altında kategoriler ve bir altında da keşfet alanı olacağını düşünelim. Bu yapıları oluşturmak için response geldiği anda tıpki bir section yapısı gibi liste oluşturarak içerisinde itemleri ekleyebilir ve bu şekilde dynamic bir collectionView yapısı oluşturabiliriz, eğer backend servisinden slider gelmezse kategori yapımız en üste çıkacaktır bunu yapmanın farklı yolları da var tabii ki fakat kodlama performansımızı ve hızımızı arttıracak bir yapı kullanmak her zaman bizim faydamıza olacaktır.</p><h3>Compositional Layout Nasıl Bir Yapıdır ?</h3><p>Compositional Layout item öğelerini bir araya getirerek group’ları group’lar ise bir araya gelerek section yapısını oluşturur, daha detaylı anlayabilmemiz için AppStore uygulamasındaki Uygulamalar sayfasına göz atabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMfNdCoOCZgQlQlXPU3ONg.png" /><figcaption>App Store Uygulamalar Sayfası</figcaption></figure><ul><li>Uygulamalar Başlığının hemen altında filtreleme yapabilmemiz için butonlar bulunuyor, aslında bu butonların her birisini <strong>“UICollectionViewCell”</strong> olarak düşünmeliyiz. Adım adım incelememiz gerekirse Burada Müzik yazan buton’u item olarak ele alabiliriz yanındaki AR Uygulamarı ve diğer butonlarla bir araya gelerek group’ları oluşturuyor ve bu groupların ekranda kapladıkları bütün alanı da section olarak adlandırabiliriz.</li><li>Hemen altında yere alan kısımda ise bir slider yapısı görüyoruz, burada da yukarıdaki durum geçerli imageview ve üstündeki yazılar birer item, hepsi bir araya gelerek group oluşturuyorlar ve ekranda kapladıkları alanı ise section olarak adlandırabiliriz.</li></ul><p>Bu yazımızda, yukarıda örneğini gördüğümüz uygulamalar sayfasının tasarımını yapacağız, bunun için ilk önce ihtiyacımız olan değişkenleri ve modelleri belirlememiz gerekiyor.</p><p>Ilk olarak ana sayfamız için hücre tiplerini belirleyeceğimiz bir enum oluşturalım,</p><pre>enum MainPageCellType {<br>    case filterCell<br>    case sliderCell<br>    case mostRecommendedCell<br>}</pre><p>Şimdi buradaki yapıda filtreleme ve slider hemen hemen aynı yapıda olduğu için bir de LayoutType adında bir enum tanımlıyoruz,</p><pre>enum LayoutType {<br>    case horizontal(isSlider: Bool)<br>    case normal(headerIdentifier: String?)<br>}</pre><p>Tiplerimizi belirtttikten sonra bu tipte oluşturacağımız hücreler için modellerini belirlememiz gerekiyor.</p><blockquote>FilterCellModel</blockquote><pre>struct FilterCellModel {<br>    let title: String<br>    let imageName: String<br>}</pre><blockquote>SliderCellModel</blockquote><pre>struct SliderCellModel {<br>    let title: String<br>    let subTitle: String<br>    let description: String<br>    let imageName: String<br>}</pre><blockquote>MostRecommendedCellModel</blockquote><pre>struct MostRecommendedCellModel {<br>    let imageName: String<br>    let title: String<br>    let description: String<br>}</pre><p>Tüm hücre tiplerimizin modellerini oluşturduk, şimdi ise anasayfada bu hücre tiplerini nasıl oluşturacağımızı ve kullanacağımızı belirlemek için SectionModel Adında bir protokol oluşturacağız ve bu protokolü kullanarak sectionlar için modellerimizi oluşturacağız</p><blockquote>SectionModel</blockquote><pre>protocol SectionModel {<br>    var sectionTitle: String? { get }<br>    var itemCount: Int { get }<br>    var cellType: MainPageCellType { get }<br>    func getItem(at index: Int) -&gt; Any<br>}</pre><blockquote>FilterSection</blockquote><pre>struct FilterSection: SectionModel {<br>    var sectionTitle: String?<br>    <br>    var filterSectionList: [FilterCellModel]<br>    <br>    var itemCount: Int {<br>        return filterSectionList.count<br>    }<br>    <br>    var cellType: MainPageCellType {<br>        return .filterCell<br>    }<br>    <br>    func getItem(at index: Int) -&gt; Any {<br>        filterSectionList[index]<br>    }<br>}</pre><blockquote>SliderSection</blockquote><pre>struct SliderSection: SectionModel {<br>    var sectionTitle: String?<br>    <br>    var sliderList: [SliderCellModel]<br>    <br>    var itemCount: Int {<br>        return sliderList.count<br>    }<br>    <br>    var cellType: MainPageCellType {<br>        return .sliderCell<br>    }<br>    <br>    func getItem(at index: Int) -&gt; Any {<br>        sliderList[index]<br>    }<br>}</pre><blockquote>MostRecommendedSection</blockquote><pre>struct MostRecommendedSection: SectionModel {<br>    var sectionTitle: String?<br>    <br>    var mostRecommendedList: [MostRecommendedCellModel]<br>    <br>    var itemCount: Int {<br>        return mostRecommendedList.count<br>    }<br>    <br>    var cellType: MainPageCellType {<br>        return .mostRecommendedCell<br>    }<br>    <br>    func getItem(at index: Int) -&gt; Any {<br>        mostRecommendedList[index]<br>    }<br>}</pre><p>Bu oluşturduğumuz modelleri MainPageViewModel üzerinde kullanalım ve artık yapımızı oluşturalım şuan burada örnek olması açısından statik şekildde ekleyeceğiz verileri fakat buradaki durum şuanlık sadece örnek olduğu için kendi istek ve ihtiyaçlarınıza göre bu listeleri güncelleyebilir veya genişletebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*5sZ0jlg1FvZt80R_DeGGjg.png" /><figcaption>MainPageViewModel Class</figcaption></figure><p>Şimdi bize gerekli modelleri de oluşturduk bundan sonra yapmamız gereken şey Compositional Layout’u oluşturmak bunun için de bir Manager class’ı yazmalıyız, ilerleyen zamanlarda ekleme çıkarma yapabiliriz ve tek bir yerden kontrol edilebilmesi okunabilirlik ve geliştirme açısından da oldukça önemli.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*VNaswEswURsNWmi7kn7qSQ.png" /><figcaption>CompositionalLayoutManager Class</figcaption></figure><p>Bu manager class’ını viewcontroller içerisinde collectionView’ımızın layout’unu oluşturmak için kullanacağız, createLayoutSection içerisinde layout tipimizi göndererek ihtiyacımız olan NSLayoutSection öğesini alacağız.</p><p>Yukarıdaki createNormalSection içerisindeki kod bloğu içerisindeki groupSize kısmında height değerini 270, item içerisindeki height değerini de 90 verdik çünkü biz en çok önerilenler kısmında alt alta 3 adet item olsun istiyoruz. Buradaki değerleri tamamen kendi ihtiyaçlarınıza göre düzenleyebilirsiniz.</p><p>ViewController içerisindeki kodumuz da bu şekilde olacak;</p><pre>func setCompositionalLayout() {<br>        let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, env -&gt; NSCollectionLayoutSection? in<br>            guard let self = self else { return nil }<br>            let sectionType = self.viewModel.getSection(at: sectionIndex).cellType<br>            <br>            return self.layoutSection(for: sectionType)<br>        }<br>        <br>        mainCollectionView.setCollectionViewLayout(layout, animated: true)<br>    }<br><br>    private func layoutSection(for cellType: MainPageCellType) -&gt; NSCollectionLayoutSection {<br>        switch cellType {<br>        case .filterCell:<br>            return CompositionalLayoutManager.sharedInstance.createLayoutSection(layoutType: .horizontal(isSlider: false))<br>        case .mostRecommendedCell:<br>            return CompositionalLayoutManager.sharedInstance.createLayoutSection(layoutType: .normal(headerIdentifier: &quot;RecommendedHeaderView&quot;))<br>        case .sliderCell:<br>            return CompositionalLayoutManager.sharedInstance.createLayoutSection(layoutType: .horizontal(isSlider: true))<br>        }<br>    }</pre><p>Ve daha önce viewModel içerisinde oluşturduğumuz verileri collectionView’ın UICollectionViewDelegate ve UICollectionViewDataSource protokollerini kullanarak ekranda göstereceğiz.</p><pre>extension MainPageViewController: UICollectionViewDelegate, UICollectionViewDataSource {<br>    func numberOfSections(in collectionView: UICollectionView) -&gt; Int {<br>        viewModel.getSectionsCount()<br>    }<br>    <br>    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {<br>        viewModel.getSection(at: section).itemCount<br>    }<br>    <br>    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {<br>        let section = viewModel.getSection(at: indexPath.section)<br>        let item = section.getItem(at: indexPath.row)<br>        switch section.cellType {<br>        case .filterCell:<br>            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FilterCollectionViewCell.reuseIdentifier, for: indexPath) as! FilterCollectionViewCell<br>            if let filterModel = item as? FilterCellModel {<br>                cell.setup(model: filterModel)<br>            }<br>            return cell<br>        case .mostRecommendedCell:<br>            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MostRecommendedCollectionViewCell.reuseIdentifier, for: indexPath) as! MostRecommendedCollectionViewCell<br>            if let mostRecommendedModel = item as? MostRecommendedCellModel {<br>                cell.setup(model: mostRecommendedModel)<br>            }<br>            return cell<br>        case .sliderCell:<br>            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: SliderCollectionViewCell.reuseIdentifier, for: indexPath) as! SliderCollectionViewCell<br>            if let sliderCellModel = item as? SliderCellModel {<br>                cell.setup(model: sliderCellModel)<br>            }<br>            return cell<br>        }<br>    }<br>    <br>    <br>    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {<br>        let section = viewModel.getSection(at: indexPath.section)<br>        let item = section.getItem(at: indexPath.row)<br>        switch section.cellType {<br>        case .filterCell:<br>            print(&quot;item : \(item as? FilterCellModel)&quot;)<br>        case .sliderCell:<br>            print(&quot;item : \(item as? SliderCellModel)&quot;)<br>        case .mostRecommendedCell:<br>            print(&quot;item : \(item as? MostRecommendedCellModel)&quot;)<br>        }<br>    }<br>}</pre><p>Ve uygulamamızı çalıştırdığımız zaman aşağıdaki gibi bir çıktı elde ediyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*qedJ_11mrBHtP6lIeYnKjQ.gif" /></figure><p>Projenin kaynak kodlarına aşağıdaki linkten ulaşabilirsiniz. Bir sonraki yazıda görüşmek üzere, herkese kolay gelsin :)</p><p><a href="https://github.com/gorkemgur/CompositionalLayoutSample">Örnek Proje Linki</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cfdb2b19911" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appcent/collectionview-i%CC%87le-compositional-layout-kullan%C4%B1m%C4%B1-7cfdb2b19911">CollectionView İle Compositional Layout Kullanımı</a> was originally published in <a href="https://medium.com/appcent">Appcent</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Xcode Snippet Nasıl Oluşturulur Ve Kullanılır ?]]></title>
            <link>https://medium.com/appcent/how-to-use-snippets-in-xcode-91d77d5c155a?source=rss-7d20cabf8527------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d77d5c155a</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Gorkem Gur]]></dc:creator>
            <pubDate>Mon, 05 Feb 2024 12:01:37 GMT</pubDate>
            <atom:updated>2024-02-05T12:22:58.542Z</atom:updated>
            <content:encoded><![CDATA[<p>Herkese selam, bu yazımızda Xcode ile kendimize ve takımımıza özgü snippet’ları nasıl oluşturacağımızı ve kullanacağımızı anlatacağım.</p><h3><strong>Snippet nedir ?</strong></h3><p>Snippet kullanımı kodlama hızımızı arttırabilecek bir özelliktir, Xcode zaten kendi içerisinde belli başlı snippet’ları barındırmaktadır. Biz kendimize özgü snippet’ları ekleyeceğiz, hem takımımızın hem de kendi kodlama hızımızı arttıracağız. Örnek vermek gerekirse aşağıdaki fotoğrafta xcode’un kendi içerisinde barındırdığı “<strong>func”</strong> snippet’ını görmekteyiz. func yazdıktan sonra bizden bir fonksiyon ismi, eğer vermemiz gerekiyorsa fonksiyon içerisine parametre ve eğer bir değer döndürmek istiyorsak return kısmını doldurmamızı söylüyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*M6HOlvx-IAuMG8tKZ5sAdg.png" /></figure><p>Şimdi biz kendimize özgü bir kaç snippet yaratabiliriz en basit örneğinden başlayalım bir feature geliştirdik ve bu feature geliştirdiğimiz class içerisinde yorum satırları bırakmamız gerekiyor bunun için kendimize bir snippet oluşturabiliriz.</p><p>İlk olarak Xcode içerisinde snippet oluşturmak istediğimiz kod parçasını seçiyoruz mesela yukarıdaki örnekten yola çıkarak kendimize ait MARK snippet’’ını oluşturalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*mPotii9qK5BGpplcTgCYAg.png" /></figure><p>Yazdığımız comment satırını seçip sağ tıkladık daha sonrasında burada Create Code Snippet… yazan alana tıklıyoruz ve bize yukarıdaki gibi Library sekmesini açıyor (cmd + shift + L kombinasyonu ile açtığımız kısım)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*EdtuEZVPirVca91JEZG99g.png" /></figure><p>Yukarıdaki fotoğrafta görüldüğü üzere burada bizden bu snippet için bir isim istiyor My Code Snippet yazan kısıma snippet’ımızın adını vereceğiz şimdilik Section Comment Şeklinde bir isim verelim.</p><p>Ve aşağıda gördüğünüz gibi bizim seçtiğimiz kod parçası, yorum satırı geldi peki biz her seferinde her yorum satırı için veya diğer snippet kullanımlarında bu şekilde her section için snippet mı oluşturacağız ? Hayır.</p><h3>Placeholder Oluşturma</h3><p>Bunun için özel bir argüman kullanarak buraya bir placeholder ekleyeceğiz <strong>&lt;#inputSection#&gt; “&lt;##&gt;” </strong>yazdığım alana kullanıcıya predefined olarak bir hint vermeliyiz kullanıcı buraya ne girebileceğini anlaması gerekiyor, örneğin <strong>&lt;#nameOfSection#&gt;</strong> yazabiliriz.</p><p>Düzenledikten sonra kodumuz şu şekilde gözükmeli;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*Tj9L1nFCz0xOtTEdfQkO-g.png" /></figure><p>Burada Language ve Platform’u All şeklinde bırakabiliriz, Completion kısmı ise bizim bu code snippet’ı nasıl çağıracağımızı belirttiğimiz kısım olacak ben <strong>mark-section</strong> şeklinde tanımladım herhangi bir dosya içerisinde <strong>mark-section</strong> yazdığım zaman yukarıda tanımlamış olduğumuz code snippet oluşacak.<br>Avaibility kısmı ise biraz daha geniş kapsamlı aslında, yazdığımız snippet’ın hangi durumlarda görünebilir olacağını belirleyebiliriz;</p><ol><li><strong>All:</strong> Her yerde görüntüleyebilir ve kullanabiliriz.</li><li><strong>Class Implementation: </strong>Adından da anlaşılacağı üzere bir class içerisinde kullanmamıza olanak sağlar.</li><li><strong>Code Expression: </strong>Bir kod bloğu içerisinde kullanmamıza olanak sağlar.</li><li><strong>Function Or Method:</strong> Bir fonksiyon veya method içerisinde kullanmamıza olanak sağlar.</li><li><strong>String Or Comment: </strong>Bir string veya comment içerisinde kullanmamıza olanak sağlar.</li><li><strong>Top Level: </strong>Bir class dışında veya function dışında kullanmamıza olanak sağlar geneldde class’ın en üstünde kullanacağı zaman seçilmesi uygundur.</li></ol><h3>Code Snippet’ın Konumu</h3><p>Tamam, kendimize ait bir snippet oluşturduk peki bu snippet’a nereden ulaşabiliriz ? Bu snippet’ı ekip arkadaşlarımıza nasıl ulaştırabiliriz ?<br>Bunun için bir kaç terminal komutunu kullanmamız gerekecek;</p><pre>cd ~/Library/Developer/Xcode/UserData</pre><p>Bu komut ile UserData klasörü içerisine gireceğiz daha sonra <strong>“ls”</strong> komutunu yazarak burada CodeSnippets adında bir dosya olup olmadığına bakacağız ama yukarıdaki adımları tamamladıysanız sizde de bu dosyanın görünür olması gerekiyor, daha sonra</p><pre>cd CodeSnippets/</pre><p>komutu ile bu klasörün içerisinde giriyoruz “.codesnippet” uzantılı dosyalar göreceğiz ve muhtelemen isimleri farklı olacak, bunun nedeni snippet’ı oluşturduğumuz anda xcode’un bu dosyaları hashleyerek tutmasıdır ama önemli değil.</p><pre>EA006FC0-AF70-4299-AFEF-3E1FEFD2BB06.codesnippet</pre><p>Yukarıdaki gibi bir dosya olduğunu düşünelim;</p><pre>open -a TextEdit EA006FC0-AF70-4299-AFEF-3E1FEFD2BB06.codesnippet</pre><p>komutu ile dosyanın içeriğine bakabiliriz, eğer içerik sizin oluşturduğunuz dosya ile uyuyorsa aşağıdaki komut ile dosyanın adını değiştirip masaüstüne kopyalama işlemi yapabilirsiniz.</p><pre>mv EA006FC0-AF70-4299-AFEF-3E1FEFD2BB06.codesnippet markSection.codesnippet &amp;&amp; cp markSection.codesnippet ~/Desktop/</pre><p>Yukarıdaki komutu çalıştırdıktan sonra bu dosyayı <strong>markSection.codesnippet</strong> olarak masaüstünde görebilirsiniz, bundan sonra yapmanız gereken tek işlem bu dosyayı takım arkadaşlarınıza atarak yukarıda belirtilen dosya yoluna kopyalamalarını istemek olacaktır.</p><p>Not: Eğer takım arkadaşlarınızda <strong>UserData</strong> içerisinde <strong>CodeSnippets</strong> klasörü yok ise <strong>“mkdir CodeSnippets” </strong>komutu ile klasörü oluşturmalarını ve içerisinde atmasını söyleyebilirsiniz.</p><p>Tüm adımları tek tek açıkladım umarım atladığım kısım olmamıştır, herkese kolay gelsin.. Bir sonraki yazıda görüşmek üzere :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d77d5c155a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appcent/how-to-use-snippets-in-xcode-91d77d5c155a">Xcode Snippet Nasıl Oluşturulur Ve Kullanılır ?</a> was originally published in <a href="https://medium.com/appcent">Appcent</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Use UIStackView Like TableView]]></title>
            <link>https://medium.com/mobiroller-tech/how-to-use-uistackview-like-tableview-5e8ddefff055?source=rss-7d20cabf8527------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e8ddefff055</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[tableviews]]></category>
            <category><![CDATA[stack-view]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Gorkem Gur]]></dc:creator>
            <pubDate>Mon, 19 Sep 2022 08:22:11 GMT</pubDate>
            <atom:updated>2022-09-20T22:35:10.478Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we are going to learn how to use UIStackView as UITableView and UIView as UITableViewCell.</p><h4><strong>So why do we need this usage?</strong></h4><ul><li>If you don’t want to define or deal with tableview’s data source and delegate methods so long story short if you want to reduce complexity you can choose to use UIStackView,</li><li>You may have to use a scrollview on the page to be designed, etc.</li></ul><p>We set our use case in the list above. Now we have to think about how to set up an algorithm to use UIStackView as TableView.</p><h4>First, we need a UIView to display the incoming data. Then when this UIView is clicked we need to get the clicked index and the model from clicked view.</h4><p>So let’s create a design file (I used xib but you can use storyboard or whatever you want like programmatically it does not matter).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glS_CG1NOsoIb8V1KSsvog.png" /><figcaption>Basic Design For Usage StackView</figcaption></figure><blockquote>Then, We will use the nibloadable extension to create our interface. We need to integrate Nibloadable to our custom View , like the below code.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9e00b2dcf239e1bbbb2ef53717d4cb1/href">https://medium.com/media/e9e00b2dcf239e1bbbb2ef53717d4cb1/href</a></iframe><h4>We should create UIStackViewExtension</h4><p>We will create UIStackViewExtension in terms of readability, we do not want complicated code blocks in ViewController.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b30308152474275edfc91b22ba3abf07/href">https://medium.com/media/b30308152474275edfc91b22ba3abf07/href</a></iframe><p>After the create this extension we need to use these function in our ViewController with UIStackView.</p><p>Let’s check ExampleStackViewController</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/078a646c2b2f201cf2f3be25c6c3fb6f/href">https://medium.com/media/078a646c2b2f201cf2f3be25c6c3fb6f/href</a></iframe><p>We will do main operations via above codes. If you can look carefully we added tag to each MockView because we need to get clicked index when user tapped the rows of stackView.</p><h4>There are 2 items to consider here.</h4><ul><li>You need to set UITapGestureRecognizer in for loop for each MockView,</li><li>You have to add tags in for loop and use these tags in TapGestureRecognizer function to get the row the user clicked.</li></ul><p>That’s it you can use your UIStackView as UITableView, long story short our UIStackView becomes UITableView and our MockView becomes UITableViewCell now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*OxLRu6_U-p2ekB4hzFMUvg.gif" /><figcaption>ExampleStackViewUsage App Preview</figcaption></figure><p>I have tried to cover most of the things, but if something left please feel free to ask me :)</p><p>You can check full code of Project here:</p><p><a href="https://github.com/gorkemgur/ExampleStackViewApp">GitHub - gorkemgur/ExampleStackViewApp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e8ddefff055" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobiroller-tech/how-to-use-uistackview-like-tableview-5e8ddefff055">How To Use UIStackView Like TableView</a> was originally published in <a href="https://medium.com/mobiroller-tech">Mobiroller Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Use Git Pre Commit On Our Projects]]></title>
            <link>https://medium.com/mobiroller-tech/how-to-use-git-pre-commit-on-our-projects-f5b1d9c16aad?source=rss-7d20cabf8527------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5b1d9c16aad</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[gitflow]]></category>
            <category><![CDATA[pre-commit]]></category>
            <dc:creator><![CDATA[Gorkem Gur]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 18:23:52 GMT</pubDate>
            <atom:updated>2022-06-17T18:52:22.120Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Everyone,<br>We’ll learn integration of git pre commit to our project in this article.</p><p>Let’s start, so what is the git hook or git pre-commit with an example. Let me explain this :) Let’s say we have development mode, this mode changes some features in the project but you don&#39;t want to show these changes to your customers or testers. So how you can achieve this goal ? Actually, you have a lot of options to do this. For example; I can remove related files before committing and pushing them to repo. That’s the best option on my opinion, what if you forgot to remove that line and 100 users installed your app to their devices, that’s gonna be terrible user experience. This mistake you make during the development process may damage your reputation with some customers.</p><p>First of all we are human and we can forget somethings right ? There is a good solution about this situation and it is called git pre-commit. That solution does not allow developers to commit unwanted lines or code blocks.</p><p>You and your team need to know little bit terminal commands to run script and if you want to customize pre-commit you need to learn bash script (basic level).</p><p>We do not need to install any extension except git :). If you are a curious person, you may have seen these files before</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*QKpBOv6E48dHDsuO0fmAmQ.png" /><figcaption>Listing Project Files</figcaption></figure><p>You can type <strong>cd .git. </strong>command and you can see the hooks file with ls -la command, after you see the hooks file you need to type<strong>cd hooks</strong> command to enter file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*4q1v79SXBwbmT_HdyzrS0A.png" /><figcaption>Git Hook Samples Under The Hooks Folder</figcaption></figure><p>You can see above the image there are the necessary sample files under the hooks folder.In this article we will use pre-commit file with symlink (i will explain why we need to use that).</p><p>Here we are! Finally we can create our pre-commit file, first you need to create a folder called .hooks in your project folder</p><ul><li>cd ~/Documents/Github/ExampleApp (It’s my project path you need to write your own project file path)</li><li>touch setup.sh</li><li>mkdir .hooks</li><li>cd .hooks/</li><li>touch pre-commit</li><li>sudo chmod +x ../setup.sh</li></ul><p>We created the necessary files with above code the next step is creating our setup.sh (the developer team need to run this bash script on their terminal)</p><p>So what is the setup.sh ? This file is linking our pre-commit file to .git/hooks/pre-commit file and we need to say, git you need to use our .hooks file you do not need to .git/hooks/ file.</p><pre>#setup.sh</pre><pre>ln -s -f $(pwd)/.hooks/pre-commit .git/hooks/pre-commit<br>git config core.hooksPath $(pwd)/.hooks<br>sudo chmod +x $(pwd)/.hooks/pre-commit<br>echo pre-commit &gt;&gt; $(pwd)/.git/info/exclude</pre><ul><li>First line is linking our pre-commit to git pre-commit,</li><li>The second line is tells the git path of the our .hooks/ file,</li><li>The third line is important because we need to give access pre-commit file to check our tracked / untracked, modified files</li></ul><p>Then the last line is very important this line is excluding our pre-commit file of our condition in pre-commit file (It’s complicated but i will explain that so do not worry.)</p><p>So we created our setup.sh we need to develop our pre-commit file. I develop this file to my own needs your situation can be different. I do not want to commit if the file contents a string like developmentMode(true)</p><pre>#pre-commit</pre><pre>#!/bin/bash</pre><pre>#declared an array if we need one more than string<br>declare -a unallowedStringsArray=(&#39;developmentMode(true)&#39;)</pre><pre>#we need to search our string in files if files contains<br>#that string commit&#39;ll be rejected with error message</pre><pre>for i in &quot;${unallowedStringsArray[@]}&quot;<br>do<br>    git diff --cached --name-only | xargs grep --with-filename $i &amp;&amp; echo &quot;COMMIT REJECTED! Found &#39;$i&#39; references. Please remove them before commiting.&quot; &amp;&amp; exit 1<br>done</pre><pre>exit 0</pre><p>And finally we can use our customized files and share the our developer team :)</p><p>You just need to commit these changed files to your repo, do not forget to explain how to run setup.sh the developer team with belowe codes</p><ul><li>sudo chmod +x setup.sh</li><li>./setup.sh</li></ul><p>The Final Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*JVA4lpJqb_QCCEGDMeY8_g.png" /><figcaption>Sample Pre-Commit Usage</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5b1d9c16aad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobiroller-tech/how-to-use-git-pre-commit-on-our-projects-f5b1d9c16aad">How To Use Git Pre Commit On Our Projects</a> was originally published in <a href="https://medium.com/mobiroller-tech">Mobiroller Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Localizable and Use for Swift]]></title>
            <link>https://medium.com/mobiroller-tech/how-to-create-localizable-and-use-for-swift-7dc66c6c007e?source=rss-7d20cabf8527------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dc66c6c007e</guid>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Gorkem Gur]]></dc:creator>
            <pubDate>Mon, 04 Apr 2022 09:32:45 GMT</pubDate>
            <atom:updated>2022-06-17T18:53:56.199Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>We are using localizable files to support other languages for example, we created an English-based application but our users need to see their language on our app. What should we do ?</strong></blockquote><p>We need to import these files to our project and translate our string variables to their languages.</p><pre>//  String+LocalizedBundleTableName.swift<br>//  Localize_Swift<br>//<br>//  Created by Vitalii Budnik on 10/7/16.<br>//  Copyright © 2016 Roy Marmelstein. All rights reserved.<br>//<br><br>import Foundation<br><br>public extension String {<br>    <br>    func localized(using tableName: String?, in bundle: Bundle?) -&gt; String {<br>        let bundle: Bundle = bundle ?? .main<br>        if let path = bundle.path(forResource: LocalizeExample.currentLanguage(), ofType: &quot;lproj&quot;),<br>            let bundle = Bundle(path: path) {<br>            return bundle.localizedString(forKey: self, value: nil, table: tableName)<br>        }<br>        else if let path = bundle.path(forResource: LCLBaseBundle, ofType: &quot;lproj&quot;),<br>            let bundle = Bundle(path: path) {<br>            return bundle.localizedString(forKey: self, value: nil, table: tableName)<br>        }<br>        return self<br>    }<br> <br>    func localizedFormat(arguments: CVarArg..., using tableName: String?, in bundle: Bundle?) -&gt; String {<br>        return String(format: localized(using: tableName, in: bundle), arguments: arguments)<br>    }<br>   <br>    func localizedPlural(argument: CVarArg, using tableName: String?, in bundle: Bundle?) -&gt; String {<br>        return NSString.localizedStringWithFormat(localized(using: tableName, in: bundle) as NSString, argument) as String<br>    }<br>    <br>}</pre><pre>//<br>//<br>//  Localize.swift<br>//  Localize<br>//<br>//  Created by Roy Marmelstein on 05/08/2015.<br>//  Copyright © 2015 Roy Marmelstein. All rights reserved.<br>//</pre><pre>import UIKit</pre><pre>/// Internal current language key<br>let LCLCurrentLanguageKey = &quot;LCLCurrentLanguageKey&quot;</pre><pre>/// Internal current language key<br>let LCLAppleLanguagesKey = &quot;AppleLanguages&quot;</pre><pre>/// Default language. English. If English is unavailable defaults to base localization.<br>let LCLDefaultLanguage = &quot;en&quot;</pre><pre>/// Base bundle as fallback.<br>let LCLBaseBundle = &quot;Base&quot;</pre><pre>/// Name for language change notification<br>public let LCLLanguageChangeNotification = &quot;LCLLanguageChangeNotification&quot;</pre><pre>/**<br>Swift 1.x friendly localization syntax, replaces NSLocalizedString<br>- Parameter string: Key to be localized.<br>- Returns: The localized string.<br>*/<br>public func Localized(_ string: String) -&gt; String {<br>    return string.localized<br>}</pre><pre>/**<br> Swift 1.x friendly localization syntax with format arguments, replaces String(format:NSLocalizedString)<br> - Parameter string: Key to be localized.<br> - Returns: The formatted localized string with arguments.<br> */<br>public func Localized(_ string: String, arguments: CVarArg...) -&gt; String {<br>    return String(format: string.localized, arguments: arguments)<br>}</pre><pre>/**<br> Swift 1.x friendly plural localization syntax with a format argument<br> <br> - parameter string:   String to be formatted<br> - parameter argument: Argument to determine pluralisation<br> <br> - returns: Pluralized localized string.<br> */<br>public func LocalizedPlural(_ string: String, argument: CVarArg) -&gt; String {<br>    return string.localizedPlural(argument)<br>}</pre><pre>public extension String {<br>    /**<br>     Swift 2 friendly localization syntax, replaces NSLocalizedString<br>     - Returns: The localized string.<br>     */</pre><pre>/**<br>  You need to change Example.Example with your project Bundle Identifier<br>  */<br>    var localized: String {<br>        return localized(using: nil, in: Bundle(identifier: &quot;Example.Example&quot;))<br>    }</pre><pre>/**<br>     Swift 2 friendly localization syntax with format arguments, replaces String(format:NSLocalizedString)<br>     - Returns: The formatted localized string with arguments.<br>     */<br>    func localizedFormat(_ arguments: CVarArg...) -&gt; String {<br>        return String(format: localized, arguments: arguments)<br>    }<br>    <br>    /**<br>     Swift 2 friendly plural localization syntax with a format argument<br>     <br>     - parameter argument: Argument to determine pluralisation<br>     <br>     - returns: Pluralized localized string.<br>     */<br>    func localizedPlural(_ argument: CVarArg) -&gt; String {<br>        return NSString.localizedStringWithFormat(localized as NSString, argument) as String<br>    }<br>}</pre><pre>// MARK: Language Setting Functions</pre><pre>open class LocalizeExample: NSObject {<br>    <br>    /**<br>     List available languages<br>     - Returns: Array of available languages.<br>     */<br>    open class func availableLanguages(_ excludeBase: Bool = true) -&gt; [String] {<br>        var availableLanguages = Bundle.main.localizations<br>        // If excludeBase = true, don&#39;t include &quot;Base&quot; in available languages<br>        if let indexOfBase = availableLanguages.firstIndex(of: &quot;Base&quot;) , excludeBase == true {<br>            availableLanguages.remove(at: indexOfBase)<br>        }<br>        return availableLanguages<br>    }<br>    <br>    /**<br>     Current language<br>     - Returns: The current language. String.<br>     */<br>    open class func currentLanguage() -&gt; String {<br>        if let currentLanguage = UserDefaults.standard.object(forKey: LCLCurrentLanguageKey) as? String {<br>            return currentLanguage<br>        }<br>        return defaultLanguage()<br>    }<br>    <br>    /**<br>     Current character direction<br>     - Returns: The current character direction. Locale.LanguageDirection.<br>     */<br>    open class func currentCharacterDirection() -&gt; Locale.LanguageDirection {<br>        return Locale.characterDirection(forLanguage: currentLanguage())<br>    }<br>    <br>    open class func semanticAttribute() -&gt; UISemanticContentAttribute {<br>        return self.currentCharacterDirection() == .rightToLeft ? .forceRightToLeft : .forceLeftToRight<br>    }</pre><pre>/**<br>     Default language<br>     - Returns: The app&#39;s default language. String.<br>     */<br>    open class func defaultLanguage() -&gt; String {<br>        var defaultLanguage: String = String()<br>        guard let preferredLanguage = Bundle.main.preferredLocalizations.first else {<br>            return LCLDefaultLanguage<br>        }<br>        let availableLanguages: [String] = self.availableLanguages()<br>        if (availableLanguages.contains(preferredLanguage)) {<br>            defaultLanguage = preferredLanguage<br>        }<br>        else {<br>            defaultLanguage = LCLDefaultLanguage<br>        }<br>        return defaultLanguage<br>    }<br>    <br>    /**<br>     Get the current language&#39;s display name for a language.<br>     - Parameter language: Desired language.<br>     - Returns: The localized string.<br>     */<br>    open class func displayNameForLanguage(_ language: String) -&gt; String {<br>        let locale : NSLocale = NSLocale(localeIdentifier: currentLanguage())<br>        if let displayName = locale.displayName(forKey: NSLocale.Key.identifier, value: language) {<br>            return displayName<br>        }<br>        return String()<br>    }<br>}</pre><p>And the extension file should be look like that :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*_F9j8SryR2B_laFnc1W76g.png" /></figure><p>Let’s begin , First we need to create a group called support or anything but you need to remember localizable files will under this group.</p><p>As in the picture below we need to create a <strong>string</strong> file called Localizable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAUccq_8drPAEGrRhbJSDw.png" /></figure><p>Then you should to select <strong>ExampleApp’s Launchsreen.storyboard</strong> after that you should click Show the file inspector on the right side that one like a page curled at the top right. After clicked that page button you can see <strong>Localize…</strong> button right of the screen you can select language from here. If you can’t see your language in here don’t worry we will add it later , just choose English or whatever you want language from spinner and click Localize.</p><p>Well , if you couldn’t get error until this step we can create other localizable languages.</p><p>Choose ExampleApp top of the folders and then select your ExampleApp under the Project title you can see the Localizations fields. Click the “+” button and choose your localizable language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QNMA0YfVFqZs-gKBZ5b19w.png" /></figure><p>The hierarchy of the project should be like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*aa1uizVntZOpIpFiP0Vmuw.png" /></figure><p>If you have completed all the steps to get here select Localizable.strings file under the support file so should be an empty localizable file.</p><p>Sample Localization.strings file code ;</p><pre>Localizable (English) -&gt;</pre><pre>//MARK: - GENERAL USAGE</pre><pre>&quot;example-message&quot; = &quot;Example Label&quot;;</pre><pre>Localiable (Turkish) -&gt;</pre><pre>//MARK: - GENERAL USAGE</pre><pre>&quot;example-message&quot; = &quot;Örnek Yazı&quot;;</pre><p>For ViewController we can use the following example structure</p><pre>Class MainViewController {</pre><pre>private struct Constants {</pre><pre>static variableName: String { return &quot;example-message&quot;.localized }</pre><pre>}</pre><pre>func setup() {</pre><pre>exampleLabel.text = Constants.variableName</pre><pre>}</pre><pre>}</pre><blockquote><strong>You can see we need to put “:” like C Programming Language :) at the end of line and we can use our variables.</strong></blockquote><p>If You want to use localizable file with storyboard you need to create extension like that</p><pre>import Foundation<br>import UIKit</pre><pre>public extension UILabel {</pre><pre><a href="http://twitter.com/IBInspectable">@IBInspectable</a> public var localizedText: String? {<br>        get {<br>            return text<br>        }<br>        set {<br>            text = NSLocalizedString(newValue ?? &quot;&quot;, comment: &quot;&quot;)<br>        }<br>    }</pre><pre>}</pre><p>The example code above allow us to access our localizable variables from xib(design) file while using storyboard.</p><p>Finally! We got the result on simulator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Cp-bT0OI95E7ZU9jVFD1_A.gif" /><figcaption>Final Result Of Localization</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dc66c6c007e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobiroller-tech/how-to-create-localizable-and-use-for-swift-7dc66c6c007e">How to Create Localizable and Use for Swift</a> was originally published in <a href="https://medium.com/mobiroller-tech">Mobiroller Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>