<?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 Yasin Özmen on Medium]]></title>
        <description><![CDATA[Stories by Yasin Özmen on Medium]]></description>
        <link>https://medium.com/@yasinozmeen?source=rss-15efb0b7efee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ujQBOWxfVN6bKBDm4pFgpw@2x.jpeg</url>
            <title>Stories by Yasin Özmen on Medium</title>
            <link>https://medium.com/@yasinozmeen?source=rss-15efb0b7efee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:15:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yasinozmeen/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[Introduction to clean code for Jr: Dependency Injection]]></title>
            <link>https://yasinozmeen.medium.com/introduction-to-clean-code-for-jr-dependency-injection-93050da6665f?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/93050da6665f</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 09:06:30 GMT</pubDate>
            <atom:updated>2023-06-23T09:08:20.239Z</atom:updated>
            <content:encoded><![CDATA[<h4>I would like to say hello and welcome to everyone who loves and cherishes Jr. ❤️</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xK7TJZKRkgtim9Gf" /><figcaption>Photo by <a href="https://unsplash.com/@ffstop?utm_source=medium&amp;utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Bu yazının türkçesi için bu makaleye bakabilirsiniz. ⬇️</p><p><a href="https://yasinozmeen.medium.com/jr-lar-i%C3%A7in-temiz-koda-giri%C5%9F-dependency-injection-cafd3b95083e">Jr.lar için temiz koda giriş: Dependency Injection</a></p><p>I said in my previous article for jr.s who want to be mid, but now that they want us to go through a camel’s ditch even to become jr, I think if we want to become jr directly, we need to learn this and similar clean architecture structures and apply them to our code, otherwise we can’t even become jr, let alone mid(!) in 6 months 🥲. So we have to improve ourselves and I will start without further ado.</p><p>I think you remember my previous article with the Delegate pattern, if you don’t remember and if you ask what the delegate pattern is, you can first look here.</p><p><a href="https://yasinozmeen.medium.com/6-ayda-mid-olmak-i%CC%87steyen-jr-lar-i%C3%A7in-swift-delegation-pattern-e890f8fba6d6">6 Ayda(!) Mid Olmak İsteyen Jr.lar için: Swift Delegation Pattern</a></p><p>This is the first part of a series of 3 articles, in this article we will talk about why we use DI (Dependency Injection) and the most used form of DI. <br>I will talk about Constructor Injection.</p><p>DI I will make the same application in 2 parts so that the main focus in all the articles I explain is the structure, a simple application that takes photos from Unsplash and shows us.</p><h4>Why do we suffer this torment?</h4><p>The most important reason is <strong>TEST TEST TEST TEST.<br></strong>Nobody is forcing us to do this to torture us. It is the last item of the SOLID principle, which leads us in terms of clean code understanding, and in general, it aims to reduce our dependency, reduce and eliminate our dependency on the objects, classes, etc. we use, thus allowing us to write more flexible, testable and developable code.</p><h3>Constructor Injection</h3><p>In this article I will talk about Constructor Injection, which is the most used form of DI, and in the other article I will talk about the other two most used ones.</p><h4>View</h4><p>There will just be a huge UIImageView on the screen and a button below it. <br>I will pin them to the screen with SnapKit again.</p><pre>class Interface:UIView {<br>    // MARK: - UI Elements<br>    private let image: UIImageView = {...}()<br>    private let button: UIButton = {...}()<br>    private let activityIndicator: UIActivityIndicatorView = {...}()<br>    <br>    // MARK: - Life Cycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configureUI()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configureUI() {<br>        backgroundColor = .systemGray5<br>        setupImageView()<br>        setupButton()<br>        setupActivityIndicator()<br>    }<br>    <br>    // MARK: -  Actions<br>    @objc func buttonDidTapped(){<br>    }<br>}<br><br>// MARK: - SnapKit Part<br>extension Interface {...}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*-tWRHAsiixv7P0MiKVwFOg.png" /><figcaption>This is what our app looks like</figcaption></figure><h3>Network Layer</h3><p>Now let’s write the Network layer for our application to download images, for this I use Alamofire and AlamofireImage.</p><p><a href="https://github.com/Alamofire/AlamofireImage">GitHub - Alamofire/AlamofireImage: AlamofireImage is an image component library for Alamofire</a></p><h4>First of all, let’s think about what internet related operations we are going to do.</h4><ol><li>We will send our API request, parse the incoming data.</li><li>We will download the image using AlamofireImage with the url in the incoming data.</li></ol><p><strong>Let’s create a 2-stage layer for these operations, a Service layer and a Manager layer.</strong></p><blockquote>We can think of our Service layer as Restaurant, our Manager layer as Order Applications and the ViewModel layer we will come to in the future as the orderer.</blockquote><p>Now let’s get down to the core of the business again and explain it one by one. <br>For the service part, this is the part where it is actually done. When you request a lahmacun from the application (Manager), you usually don’t give too much detail, you just choose the restaurant at first. How the lahmacun is made is entirely the restaurant’s own business. Our restaurant prepares the food with the Service layer and Alamofire, when the food is done, it gives the food to the courier (order app) and the courier brings the food to us.</p><p>Also <a href="https://medium.com/u/3bc09fa68f6b">burrakerden</a> has a very nice article about how the restaurant makes the food, <a href="https://medium.com/@burrakerden/introduction-to-networking-in-ios-development-with-alamofire-b7ae419cec97">you can find it here</a>.</p><p>Below we see how the restaurant makes the dish.</p><pre>protocol GetDataProtocol: AnyObject {<br>    func fetch&lt;T&gt;(path: String, onSuccess: @escaping (T) -&gt; Void, onError: @escaping (AFError) -&gt; Void) where T: Codable<br>}<br><br>final class GetDataService:GetDataProtocol {<br>   func fetch&lt;T&gt;(path: String, onSuccess: @escaping (T) -&gt; Void, onError: @escaping (AFError) -&gt; Void) where T: Codable {<br>        AF.request(path, encoding: JSONEncoding.default).validate().responseDecodable(of: T.self) { (response) in<br>            guard let model = response.value else {<br>                print(response)<br>                return<br>            }<br>            onSuccess(model)<br>        }<br>    }<br>}</pre><pre>protocol GetImageProtocol: AnyObject {<br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;())<br>}<br><br>final class GetImageService:GetImageProtocol {<br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;()) {<br>        AF.request(url).responseImage { response in<br>            if case .success(let image) = response.result {<br>                onSuccess(image.cgImage)<br>            }else {<br>                onError(&quot;error when image dowloand&quot;)<br>            }<br>        }<br>    }<br>}</pre><p>GetDataService is already explained in Burak’s article. GetImageService is not much different, we actually give a url and if the operation is successful, it returns us cgImage in the completion handler and if the operation fails, it returns us the error message.</p><p>Let’s see how the Order application takes orders. <br>This is exactly where Dependency Injection comes in. As you remember, we had already decided in advance that we would order lahmacun, but we didn’t know which restaurant to order it from. The init part here will run while we are ordering and will ask us which restaurant we want. Since we want lahmacun to come from the Service layers we have created, we will give those layers at the time of init.</p><pre>class GetDataManager {<br>    private let getDataService: GetDataProtocol<br>    private let url:String<br>    <br>    init(getDataService: GetDataProtocol) {<br>        self.getDataService = getDataService<br>        self.url = UnsplashUrl.url.rawValue<br>    }<br>    <br>    func getJsonData(onSuccess: @escaping (UnsplashData?)-&gt;(Void), onError: @escaping (String)-&gt;(Void)) {<br>        getDataService.fetch(path: url) { (response:UnsplashData) in<br>            onSuccess(response)<br>        } onError: { error in<br>            onError(error.localizedDescription)<br>        }<br>    }<br>}</pre><pre>class GetImageManager {<br>    private let getImageService: GetImageProtocol<br>    <br>    init(getImageService: GetImageProtocol) {<br>        self.getImageService = getImageService<br>    }<br>    <br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;()) {<br>        getImageService.getImage(url:url){ cgImage in<br>            onSuccess(cgImage)<br>        } onError: { error in<br>            onError(error)<br>        }<br>    }<br>}</pre><p>Let’s move quickly to the ViewModel Side so that it is well understood</p><pre>protocol ViewModelProtocol: AnyObject {<br>    func getData()<br>    func getPhoto()<br>    var data:UnsplashData? { get set }<br>}<br><br>class ViewModel:ViewModelProtocol {<br>    // MARK: - Propertires<br>    var data: UnsplashData?<br>    weak var changeImageDelegate: ChangeImageProtocol?<br>    let getDataManager = GetDataManager(getDataService: GetDataService())<br>    let getImageManger = GetImageManager(getImageService: GetImageService())<br>    <br>    <br>    // MARK: - Functions<br>    func getData() {<br>        getDataManager.getJsonData { data in<br>            self.data = data<br>            self.getPhoto()<br>        } onError: { error in<br>            print(error)<br>        }<br>    }<br>    <br>    func getPhoto() {<br>       guard let data = data else{<br>            return<br>        }<br>        getImageManger.getImage(url: data.urls.regular) { image in<br>            self.changeImageDelegate?.changeImage(image)<br>        } onError: { error in<br>            print(error as Any)<br>        }<br>    }<br>}</pre><p>As you can see, when we add the getDataManager, it asks us for service in the init method, we currently give GetDataService, but in the future, maybe instead of doing it with Alamofire, we will want to do it with URLSession, in such a case, all we need to do is to give that service class, instead of changing our code from top to bottom, we can continue on our way by updating a small place.</p><p>If we need to explain what we are doing, when the getData function runs, it goes to the getJsonData method of the getDataManager and it returns UnsplashData when the operation is successful, we assign it to the variable that comes with the protocol and call the getPhoto method immediately afterwards.</p><p>The getPhoto method accesses the Interface through changeImageDelegete and updates the Image. Let’s see how we did that part.</p><pre>protocol ChangeImageProtocol: AnyObject{<br>    func changeImage(_ image:Image)<br>}<br><br>class Interface:UIView {<br>    // MARK: - Properties<br>    weak var buttonDelegate: InterfaceProtocol?<br>    private let viewModel = ViewModel()<br>.........<br>}<br>// MARK: - Change Image<br>extension Interface: ChangeImageProtocol{<br>    <br>    func changeImage(_ image: AlamofireImage.Image) {<br>        guard let cgImage = image.cgImage else {<br>            print(&quot;image not transform to cgImage&quot;)<br>            return<br>        }<br>        self.image.image = UIImage(cgImage: cgImage)<br>    }<br>}<br><br>// MARK: - SnapKit Part<br>extension Interface {...}</pre><pre>protocol InterfaceProtocol:AnyObject {<br>    func buttonDidTapped()<br>}<br>class ViewController: UIViewController {<br>    // MARK: - Properties<br>    private let viewModel = ViewModel()<br>    var interface: Interface?<br>    weak var viewModelDelegate: ViewModelProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        delegateImp()<br>        getFirstData()<br>    }<br>    <br>    // MARK: - Funcitons<br>    func configureUI() {...}<br>    <br>    func delegateImp() {<br>        interface?.buttonDelegate = self<br>        viewModel.changeImageDelegate = interface<br>        viewModelDelegate = viewModel<br>    }<br>    ...<br>}<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*o4AmD-ba2bH9N_5vkwpyDw.gif" /><figcaption>This is the final version of our application</figcaption></figure><p>Normally our topic is complete and there is no Dependency Injection left, but I want to run an activityIndicator while the images are loading, so I’m posting the finished version on github.</p><p><a href="https://github.com/yasinozmeen/DependecyInjectionExample">GitHub - yasinozmeen/DependecyInjectionExample: this repo was created for the training article</a></p><p>If you like my article or if you don’t like it, I would be very happy if you leave feedback If you want to see my articles in this style, you can follow me here and twetter ❤️</p><p><a href="https://twitter.com/yasinozmeen">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93050da6665f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jr.lar için temiz koda giriş: Dependency Injection]]></title>
            <link>https://yasinozmeen.medium.com/jr-lar-i%C3%A7in-temiz-koda-giri%C5%9F-dependency-injection-cafd3b95083e?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/cafd3b95083e</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 17:59:40 GMT</pubDate>
            <atom:updated>2023-06-20T20:51:08.444Z</atom:updated>
            <content:encoded><![CDATA[<h4>Jr.ları seven ve yaşatan herkese merhaba ve hoş geldiniz demek istiyorum. ❤️</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D1aXSbJEzJwojVoq" /><figcaption>Photo by <a href="https://unsplash.com/@maxcodes?utm_source=medium&amp;utm_medium=referral">Maxwell Nelson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Ben bir önceki yazıma mid olmak isteyen jr.lar için dedim ama artık jr olmak için bile deveye hendek atlatmamızı istedikleri için bence direk jr olmak istiyorsak bu ve bunun gibi clean architecture yapılarını öğrenmemiz ve kodumuza uygulamamız lazım yoksa bırakın 6 ayda mid olmayı(!) jr bile olamıyoruz 🥲. O yüzden kendimizi geliştirmek zorundayız ve ben daha fazla uzatmadan başlıyorum.</p><p>Bir önceki Delegate pattern ile olan yazımı hatırlıyorsunuzdur diye düşünüyorum hatırlamıyorsanız ve delegate pattern de ne olaki diyorsanız öncelikle şuraya bakabilirsiniz.</p><p><a href="https://yasinozmeen.medium.com/6-ayda-mid-olmak-i%CC%87steyen-jr-lar-i%C3%A7in-swift-delegation-pattern-e890f8fba6d6">6 Ayda(!) Mid Olmak İsteyen Jr.lar için: Swift Delegation Pattern</a></p><p>Bu 3 yazılık bir serininin ilk bölümü, bu yazımızda neden DI(Dependency Injection) kullandığımızdan ve bu DI’nin en çok kullanılan şekli olan <br><strong>Constructor Injection</strong>’dan bahsedeceğim.</p><p>DI Anlattığım Yazıların hepsinde asıl odaklanılması gereken kısmın yapı olması için 2 bölümde de aynı uygulamayı yapacağım, Unsplash’dan fotoğraf çekip bize gösteren basit bir uygulama.</p><h4>Neden çekiyoruz bu eziyeti ?</h4><p>En önemli nedeni <strong>TEST TEST TEST</strong>.<br>Kimse bize eziyet olsun diye bunu yapmaya zorlamıyor. Temiz kod anlayışı açısından bize öncülük eden SOLID prensibinin de son maddesidir ve genel olarak kullandığımız nesnelerde sınıflarda vs bizim bağımlılığımızı, azaltmamızı yok etmemizi hedefler bu şekilde daha esnek, test edilebilir ve geliştirilebilir kod yazabilmemize olanak sağlar.</p><h3><strong>Constructor Injection</strong></h3><p>Bu yazımda DI’nin en çok kullanılan şekli olan Constructor Injection’dan bahsedeceğim diğer yazımda da diğer en çok kullanılan ikisine değineceğim.</p><h4>View</h4><p>Ekranda kocaman bir UIImageView ve altında da bir buton olacak sadece. <br>Bunları yine SnapKit ile ekrana sabitleyeceğim.</p><pre>class Interface:UIView {<br>    // MARK: - UI Elements<br>    private let image: UIImageView = {...}()<br>    private let button: UIButton = {...}()<br>    private let activityIndicator: UIActivityIndicatorView = {...}()<br>    <br>    // MARK: - Life Cycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configureUI()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configureUI() {<br>        backgroundColor = .systemGray5<br>        setupImageView()<br>        setupButton()<br>        setupActivityIndicator()<br>    }<br>    <br>    // MARK: -  Actions<br>    @objc func buttonDidTapped(){<br>    }<br>}<br><br>// MARK: - SnapKit Part<br>extension Interface {...}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*vIOoLx-DS38YnSl5R5IIrg.png" /><figcaption>Uygulamamız böyle görünüyor</figcaption></figure><h3>Network Katmanı</h3><p>Şimdi uygulamamızın resim indirmesi için gerekli olan Network katmanını yazalım, bu iş için Alamofire ve AlamofireImage kullanıyorum.</p><p><a href="https://github.com/Alamofire/AlamofireImage">GitHub - Alamofire/AlamofireImage: AlamofireImage is an image component library for Alamofire</a></p><h4><strong>Öncelikle internetle ilgili hangi işlemleri yapacağımızı düşünelim.</strong></h4><ol><li>API isteğimizi göndereceğiz, gelen datayı parse edeceğiz.</li><li>Gelen datadaki url ile AlamofireImage kullanarak resmi indireceğiz.</li></ol><p><strong>Bu işlemler için 2 aşamlı bir katman oluşturalım, bir Service katmanı bir de Manager katmanı.</strong></p><blockquote><strong><em>Servis katmanlarımızı </em></strong><em>R</em>estoran<strong><em>, Manager katmanlarımızı Sipariş Uygulamaları ve ileride geleceğimiz ViewModel katmanını da sipariş veren biz olarak düşünebiliriz.</em></strong></blockquote><p>Şimdi yine işin asıl özüne inelim ve tane tane anlatalım. <br>Servis kısmı için asıl yapıldığı kısım. Siz uygulamadan(Manager’dan) bir lahmacun istediğiniz zaman genellikle çok fazla detay vermezsiniz sadece restoranı seçersiniz en başta. Lahmacunun nasıl yapıldığı tamamen restoranın kendi işidir. Bizim Restoranımız burda Service katmanı ve Alamofire ile yemeği hazırlıyor, yemek bittiği zaman kuryeye(sipariş uygulaması) yemeği veriyor ve kurye yemeği bize getiriyor.</p><blockquote>Ayrıca restoranın yemeği nasıl yaptığını anlatan <a href="https://medium.com/u/3bc09fa68f6b">burrakerden</a>&#39;in çok güzel bir yazısı var <a href="https://medium.com/@burrakerden/introduction-to-networking-in-ios-development-with-alamofire-b7ae419cec97">yazıya burdan ulaşabilirsiniz.</a></blockquote><p>Aşşağıda restoranın yemeği nasıl yaptığını görüyoruz.</p><pre>protocol GetDataProtocol: AnyObject {<br>    func fetch&lt;T&gt;(path: String, onSuccess: @escaping (T) -&gt; Void, onError: @escaping (AFError) -&gt; Void) where T: Codable<br>}<br><br>final class GetDataService:GetDataProtocol {<br>   func fetch&lt;T&gt;(path: String, onSuccess: @escaping (T) -&gt; Void, onError: @escaping (AFError) -&gt; Void) where T: Codable {<br>        AF.request(path, encoding: JSONEncoding.default).validate().responseDecodable(of: T.self) { (response) in<br>            guard let model = response.value else {<br>                print(response)<br>                return<br>            }<br>            onSuccess(model)<br>        }<br>    }<br>}</pre><pre>protocol GetImageProtocol: AnyObject {<br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;())<br>}<br><br>final class GetImageService:GetImageProtocol {<br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;()) {<br>        AF.request(url).responseImage { response in<br>            if case .success(let image) = response.result {<br>                onSuccess(image.cgImage)<br>            }else {<br>                onError(&quot;error when image dowloand&quot;)<br>            }<br>        }<br>    }<br>}</pre><p>GetDataService zaten Burağın yazısında anlatılıyor. GetImageService de çok farklı değil aslında bir url veriyoruz ve eğer işlem başarılır olursa bize completition handlerda cgImage döndürüyor eğer işlem başarız olursa bize hata mesajını döndürüyor.</p><p>Birde Sipariş uygulaması nasıl sipariş alıyor ona bakalım. <br>İşte tam bu kısımda Dependency Injection Karşımıza çıkıyor. Hatırlayacağınız üzere biz lahmacun isteyeceğimize zaten önceden karar vermiştik ama hangi restorandan vereceğimizi bilmiyorduk. Buradaki init kısmı biz sipariş verirken çalışıcak ve bize hangi restoranı istediğimizi soracak. Bizde oluşturduğumuz Service katmanlarından lahmacun gelmesini istediğimiz için o katmanları vereceğiz init anında.</p><pre>class GetDataManager {<br>    private let getDataService: GetDataProtocol<br>    private let url:String<br>    <br>    init(getDataService: GetDataProtocol) {<br>        self.getDataService = getDataService<br>        self.url = UnsplashUrl.url.rawValue<br>    }<br>    <br>    func getJsonData(onSuccess: @escaping (UnsplashData?)-&gt;(Void), onError: @escaping (String)-&gt;(Void)) {<br>        getDataService.fetch(path: url) { (response:UnsplashData) in<br>            onSuccess(response)<br>        } onError: { error in<br>            onError(error.localizedDescription)<br>        }<br>    }<br>}</pre><pre>class GetImageManager {<br>    private let getImageService: GetImageProtocol<br>    <br>    init(getImageService: GetImageProtocol) {<br>        self.getImageService = getImageService<br>    }<br>    <br>    func getImage(url: String, onSuccess: @escaping (CGImage?)-&gt;(), onError: @escaping (String?)-&gt;()) {<br>        getImageService.getImage(url:url){ cgImage in<br>            onSuccess(cgImage)<br>        } onError: { error in<br>            onError(error)<br>        }<br>    }<br>}</pre><p>Hızlıca ViewModel Tarafına da geçelim iyice anlaşılsın</p><pre>protocol ViewModelProtocol: AnyObject {<br>    func getData()<br>    func getPhoto()<br>    var data:UnsplashData? { get set }<br>}<br><br>class ViewModel:ViewModelProtocol {<br>    // MARK: - Propertires<br>    var data: UnsplashData?<br>    weak var changeImageDelegate: ChangeImageProtocol?<br>    let getDataManager = GetDataManager(getDataService: GetDataService())<br>    let getImageManger = GetImageManager(getImageService: GetImageService())<br>    <br>    <br>    // MARK: - Functions<br>    func getData() {<br>        getDataManager.getJsonData { data in<br>            self.data = data<br>            self.getPhoto()<br>        } onError: { error in<br>            print(error)<br>        }<br>    }<br>    <br>    func getPhoto() {<br>       guard let data = data else{<br>            return<br>        }<br>        getImageManger.getImage(url: data.urls.regular) { image in<br>            self.changeImageDelegate?.changeImage(image)<br>        } onError: { error in<br>            print(error as Any)<br>        }<br>    }<br>}</pre><p>Gördüğünüz gizi getDataManagerı eklerken init metodunda bizden service istiyor biz şu anda GetDataService verdik ama ileride belki Alamofire ile yapmak yerine URLSession ile yapmak isteyeceğiz öyle bir durumda tek yapmamız gereken o service sınıfını vermek olacak kodumuzu bastan aşağıya değiştirmek yerine ufacık bir yerini güncelleyerek yolumuza devam edebiliyoruz.</p><p>Ne yaptığımızı anlatmak gerekirse eğer, getData fonksiyonu çalıştığı zaman getDataManager’ın getJsonData methoduna gidiyor ve o da bize işlem başarılı olduğunda UnsplashData döndürüyor bunu protocol ile gelen değişkene atıyoruz ve hemen arından getPhoto methodunu çağırıyoruz.</p><p>getPhoto methodu changeImageDelegete sayesinde Interface’e erişiyor ve Image’i güncelliyor. Hadi o tarafı nasıl yaptık ona da bakalım.</p><pre>protocol ChangeImageProtocol: AnyObject{<br>    func changeImage(_ image:Image)<br>}<br><br>class Interface:UIView {<br>    // MARK: - Properties<br>    weak var buttonDelegate: InterfaceProtocol?<br>    private let viewModel = ViewModel()<br>.........<br>}<br>// MARK: - Change Image<br>extension Interface: ChangeImageProtocol{<br>    <br>    func changeImage(_ image: AlamofireImage.Image) {<br>        guard let cgImage = image.cgImage else {<br>            print(&quot;image not transform to cgImage&quot;)<br>            return<br>        }<br>        self.image.image = UIImage(cgImage: cgImage)<br>    }<br>}<br><br>// MARK: - SnapKit Part<br>extension Interface {...}</pre><pre>protocol InterfaceProtocol:AnyObject {<br>    func buttonDidTapped()<br>}<br>class ViewController: UIViewController {<br>    // MARK: - Properties<br>    private let viewModel = ViewModel()<br>    var interface: Interface?<br>    weak var viewModelDelegate: ViewModelProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        delegateImp()<br>        getFirstData()<br>    }<br>    <br>    // MARK: - Funcitons<br>    func configureUI() {...}<br>    <br>    func delegateImp() {<br>        interface?.buttonDelegate = self<br>        viewModel.changeImageDelegate = interface<br>        viewModelDelegate = viewModel<br>    }<br>    ...<br>}<br>...<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*o4AmD-ba2bH9N_5vkwpyDw.gif" /><figcaption>Uygulamamızın son hali bu şekilde</figcaption></figure><p>Normalde konumuz tamamlandı ve Dependency Injectıon ile ilgili bir işlem kalmadı ama ben resimler yüklenirken bir activityIndicator çalıştırmak istiyorum bu şekilde bitmiş halini githubda yayınlıyorum.</p><p><a href="https://github.com/yasinozmeen/DependecyInjectionExample">GitHub - yasinozmeen/DependecyInjectionExample: this repo was created for the training article</a></p><p>Eğer yazımı beğendiyseniz veyahut beğenmediyseniz feedback bırakmanız beni çok mutlu eder bu tarz yazılarımı görmek istiyorsanız beni burdan ve twetterdan takip edebilirsiniz ❤️</p><p><a href="https://twitter.com/yasinozmeen">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cafd3b95083e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[For Jr.’s Who Want to Become Mid in 6 Months(!): Swift Delegation Pattern]]></title>
            <link>https://yasinozmeen.medium.com/for-jr-s-who-want-to-become-mid-in-6-months-swift-delegation-pattern-bfc4379ad19e?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfc4379ad19e</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 12:08:57 GMT</pubDate>
            <atom:updated>2023-06-16T12:08:57.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyXvTh9YBMWpoqAQOIcPWg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@claybanks?utm_source=medium&amp;utm_medium=referral">Clay Banks</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Hello and welcome friends, in this article, I plan to explain the Delegation Pattern in the way I understand it because it’s explained the same way everywhere. There’s a vehicle protocol and since the car defined this vehicle protocol for itself, it gained the ability to drive, etc., these are entirely syntactic matters. I believe the hard part isn’t this, the hard part is us not knowing where to use it in a real application. This always happens by rote learning. In this article, I aim to explain the logic of the Delegation Pattern to you.</h4><p><em>Bu yazının Türkçesi için buraya bakabilirsiniz ⬇️<br>For the Turkish version of this article, see here ⬇️</em></p><p><a href="https://yasinozmeen.medium.com/6-ayda-mid-olmak-i%CC%87steyen-jr-lar-i%C3%A7in-swift-delegation-pattern-e890f8fba6d6">6 Ayda(!) Mid Olmak İsteyen Jr.lar için: Swift Delegation Pattern</a></p><h4>Grab your tea or coffee, a long article awaits you ☕️</h4><blockquote>If you get bored at some point or see something wrong, please provide feedback.</blockquote><p>Before we start, if you’ve never heard the terms Protocol and Closure before and you’re going to panic and close when you see them, let me take you from here.👇🏼</p><blockquote>Swift Book Official Documentation — Closure Explanation<br>Swift Closures Explained — Sean Allen</blockquote><h4>I mentioned that I wanted to go with real applications, so let’s design an app where we transfer data between two screens.</h4><p><em>I’m quickly going over the view parts.</em></p><pre>class SceneDelegate: UIResponder, UIWindowSceneDelegate {<br>    <br>    var window: UIWindow?<br>    // MARK: - UI Scene Caller<br>    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, <br>               options connectionOptions: UIScene.ConnectionOptions) {<br>        guard let windowScene = (scene as? UIWindowScene) else {return}<br>        let window = UIWindow(windowScene: windowScene)<br>        let FirstVC = FirstVC()<br>        let navController = UINavigationController(rootViewController: FirstVC)<br>        window.rootViewController = navController<br>        self.window = window<br>        self.window?.makeKeyAndVisible()<br>    }<br>}<br>/// Here, simply put, we&#39;re saying that we will start our application from a<br>/// Navigation Controller that has chosen FirstVC as the view controller.</pre><pre>final class FirstView: UIView {<br>    // MARK: - UI Elements<br>    private let firstLabel: UILabel = {...}()<br>    private let firstTF: UITextField = {...}()<br>    private let firstButton: UIButton = {...}()<br>    /// I&#39;m customizing the Label, TextField, and Button within the Closure. <br><br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    private func configure() {<br>        backgroundColor = .systemGray5<br>        setupFirstLabel()/// I&#39;ve created these three functions with an extension<br>        setupFirstTf()/// and aligned them to the screen with snapkit<br>        setupFirstButton()/// I&#39;m not filling up the screen since it&#39;s not our topic. <br>    }<br>    <br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>    }<br>    // this function will run when our button is clicked<br>}</pre><blockquote>If you want to create programmatic UI, I recommend these resources<br><a href="https://www.youtube.com/@Codebrah/about">Youtube </a><a href="https://medium.com/u/b7679c45723a">codebrah</a><br>You should learn SnapKit immediately after learning programmatic UI.</blockquote><pre>final class FirstVC: UIViewController{<br>    // MARK: - Properties<br>    var firstView: FirstView?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>}</pre><p>We are setting the view of the VC to be displayed when the screen first opens to the view we designed. So why do we initially make the firstView an optional value? Since we are equating the View to be displayed on the screen to the firstView, when the life of the ViewController ends, the life of the View we display on the screen must also end so that we can display something new on the screen, that’s why we define it as a variable like this and then equate it to the View.</p><pre>class SecondView: UIView{<br>    // MARK: - UI Elements<br>    private var secondLabel: UILabel = {...}()<br>    private let secondButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configure() {<br>        backgroundColor = .systemGray5<br>        setupSecondLabel()//These functions use SnapKit to<br>        setupSecondButton()//Help place elements on the screen<br>    }<br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>    }<br>///In this view, we define our elements in the same logic as FirstView and<br>///We configure these elements at Init.</pre><pre>class SecondVC: UIViewController{<br>    // MARK: - Varaibles<br>    var secondView: SecondView?<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>}// Everything here is the same as with FirstVC, so I&#39;m moving on.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJI1XjV7dcC6wGuwC2wvpQ.png" /><figcaption>Yes, we’ve defined our Views and ViewControllers, the application currently looks like this.</figcaption></figure><h4>Now, after these processes are done, the first thing we need to do is to identify what we want, which way would make it easier to do what I want.</h4><ol><li>Clicking the Button in FirstVC should go to SecondVC</li><li>The text in the firstTextField should be written in the secondLabel</li><li>When the secondButton is clicked, it should go to FirstVC</li></ol><p>Now let’s fulfill our requests one by one.</p><p>First, let’s write a Protocol and name it ButtonTapProtocol and mark it as AnyObject because we only want classes to adopt this protocol.<br>Also, let’s define a function in our protocol that will fulfill the task we want in item 1.</p><pre>protocol ButtonTapProtocol: AnyObject {<br>    func didTapButton()<br>}</pre><blockquote>It doesn’t matter where all this definition is made. If you are making a very large app and using the delegate pattern, you can even open a separate Swift file just for protocols and keep all of them there. Protocols can be called from anywhere, just like standard classes and structs.</blockquote><p>Now let’s go to FirstView because our first notified function is there when the button is clicked.<br>If we create an object/variable as a protocol type, that variable allows us to access the functions/content of our protocol.<br>How so? Like this ⬇️</p><pre>weak var buttonTapDelegate: ButtonTapProtocol?</pre><p><a href="https://developer.apple.com/forums/thread/692158#:~:text=The%20Swift%20book%20says%20that,are%20declared%20as%20weak%20references.%22"><em>If you’re wondering about “</em></a><a href="https://developer.apple.com/forums/thread/692158#:~:text=The%20Swift%20book%20says%20that,are%20declared%20as%20weak%20references.%22"><em>weak”, you can refer to this</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vH4-tlu7fzQ4z2qgehUaZA.png" /></figure><p>Exactly, by doing so, inside the buttonTapped() function that is triggered when the button is clicked, we will call the didTapButton function from our protocol. Why are we calling it there? Because we want the didTapButton function to be executed/called after the button is tapped. The final version of the buttonTapped() function would look like this:</p><pre>@objc func buttonTapped(){<br>    buttonTapDelegate?.didTapButton()<br>}</pre><p>So now didTapButton will work when the button is clicked, but how will it work, we have not defined the content of this function?<br>Exactly, we have not defined the content of this function, and you may also remember that.<br>Our delegate is still nil, we defined it as optional.<br>Now it’s time to fill in the meaning of our delegate. To make it a representative, a proxy.</p><p>Now let’s go to FirstVC and create a function called delegateImpemantent. <br>Let’s create it, but why should we create it?<br>As I said above, the buttonTapDelegate in our firstView page is currently nil and we need to fill it, if we need to explain the another meaning of the word Delegate, we need to give it a proxy, representative, responsible person.</p><pre>private func delegateImplemantent() {<br>    firstView?.buttonTapDelegate = self<br>}</pre><blockquote>It was easier for me to understand some things after I had this part in my head, so we can spend some time here.</blockquote><p>firstView.buttonTapDelegate = self, let’s go one by one. <br>First of all, when we say firstView, we already know that we are talking about our view class and we say that the buttonTapDelegate variable in firstView wants to be me. <br>Hmm how do you mean I want to be me?<br>Let’s call it a delegate instead of a variable, then it’s better. <br>Look now I want to be the buttonTapDelegate delegate in the firstView class. So buttonTapDelegate is actually our FirstVC but since we derived buttonTapDelegate from ButtonTapProtocol, FirstVC will be responsible for our ButtonTapProtocol related work.</p><p>In other words, when we clicked on the button, the didTapButton function was supposed to run, but FirstVC said that I am taking over this work/execution task. Well, okay, let it take over, but how will it take over, he doesn’t have this function, very true, before I could say these things Xcode❤️ got angry with me and says this ⬇️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yOuqNVB_zwMHXsoMtQUvUA.png" /></figure><p>So to translate, it says ⬇️</p><blockquote>You can’t assign buttonTapDelegate here because it wants a ButtonTapProtocol delegate, agent, employee. But if you map a ButtonTapProtocol to yourself and use the necessary functions, you can be the delegate.</blockquote><p>Well, okay, very good, that’s what we wanted and then we take the necessary actions.</p><pre>final class FirstVC: UIViewController, ButtonTapProtocol {<br>...<br>private func delegateImplemantent() {<br>    firstView?.buttonTapDelegate = self<br>}<br>func didTapButton() {<br><br>}<br>...<br>}</pre><p>As we can see above, we process the Protocol in our FirstVC class and then, after obtaining the necessary functions, Xcode stops being angry with us and we are now a registered agent, employee and officer of FirstView.</p><p><em>You know that </em><em>didTapButton that works when </em><em>firstButton is clicked, since we are now </em><em>buttonTapDelegate and the </em><em>didTapButton function is accessed through us, we can think of that function as the </em><em>didTapButton function in </em><em>FirstVC.</em></p><p>Now we can realize our 1st point. When firstButton is clicked, we just need to do the following operations to go to SecondVC.</p><pre>func didTapButton() {<br>   navigationController?.pushViewController(secondVC, animated: true)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*lnxF1Wn4WIkJooaw_VoztA.gif" /><figcaption>We’ve made our screen transition.</figcaption></figure><blockquote>Display the text value entered in firstTextField in secondLabel.</blockquote><p>Let’s think about what we need to do with what we remember from 1.item</p><ol><li>We should get the entered text value.</li><li>We should keep the text value somewhere.</li><li>Before the other screen loads, we should display this text value in secondLabel</li></ol><p>To get the entered text value, we already have a function didTapButton that runs where the text is entered, let’s add a parameter to this function to request a String value.</p><pre>func didTapButton(text: String?) {<br>  navigationController?.pushViewController(secondVC, animated: true)<br>}</pre><p><em>Let’s make it optional because maybe it will be used in other ways in the future and we can enter the text value as </em><em>nil. 😉</em></p><p>Ok, now we can get the text value, the next step is to store this value somewhere in SecondVC and wait for the other functions that need to run to show it. If we need to wait, we can’t fetch the text after going to the second screen, we need to tell the screen what to write on the screen before our screen is shown, so let’s fetch the text, store the text and tell it what to write, then go to the screen.</p><p>To do this we need a protocol and a new delegate. Let’s think about where we need to do this.</p><ul><li>As we said, it didn’t matter where the Protocol was defined, so we can create it wherever we want and name it PrepareChangeLabelNameProtocol. I say prepare it because first we have to keep the text somewhere and prepare the secondView.</li></ul><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>}</pre><ul><li>So what should be the functions of our Protocol, let’s think about what we want to do. <br>We want to prepare the SecondView to fetch, store and display the text. Then our functions should be like this. ⬇️</li></ul><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>    func getText(text: String?, handler: (()-&gt;()))<br>    func prepareChangeLabelText()<br>}</pre><ul><li>There is a completion handler in the getText Function because I want to fetch and save the text first and then see the 2nd screen.</li><li>Let’s place and create our functions respectively. I will write an extension to keep things organized.</li></ul><pre>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>    }<br>}</pre><ul><li>Let’s create a String variable at the top of SecondVC to store the value that the getText function gets when it runs, and then fill in the getText function.</li></ul><pre>class SecondVC: UIViewController{<br>    // MARK: - Varaibles<br>    var labelText:String = &quot;&quot;<br>    ...<br>}<br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>}</pre><p>After our getText method assigns the text value it receives in its parameter to our labelText variable, it goes to execute the values written in the handler. So where do we get this parameter and handler, of course in the most convenient place for us and for our scenario this is now inside the didTapButton function in FirstVC because our didTapButton function both requests the text parameter and is the last function before going to SecondVC. But first we need to do a delegate operation to use the getText function there, since we have already done this twice, I am not explaining it in detail anymore, the last carpet of our class is like this ⬇️</p><pre>final class FirstVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Properties<br>    let secondVC = SecondVC()<br>    var firstView: FirstView?<br>    var secondVCDelegate: PrepareChangeLabelNameProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>        delegateImplemantent()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>    <br>    private func delegateImplemantent() {<br>        firstView?.buttonTapDelegate = self<br>        secondVCDelegate = secondVC<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        secondVCDelegate?.getText(text: text){<br>            navigationController?.pushViewController(secondVC, animated: true)<br>        }<br>    }<br>}</pre><p>I also updated our didTapButton method and we give the text value we get from firstTextField to the getText method we access with secondVCDelegate.</p><p>Now our getText method works when we press the button and assigns the value we entered in the text field to the labelText variable.</p><p>Now it’s time to show the value in the LabelText variable in the secondLabel. We’ll use our viewWillAppear method to set this up because we want to make preparations before the screen appears and viewWillAppear runs before each time the screen appears.</p><p>We make a protocol to the SecondView that will contain the method that will change the value of the label and we will delegate this method to the viewWillAppear method of the SecondVC and the label will be prepared before the screen appears as we want.</p><pre>protocol ChangeLabelTextProtocol:AnyObject {<br>    func changeLabelText(text:String)<br>}<br>class SecondView: UIView,ChangeLabelTextProtocol {<br>    ......<br><br>    func changeLabelText(text: String) {<br>        secondLabel.text = text<br>    }<br>}</pre><p>Okayyy, now we need to appoint our delegation.</p><pre>class SecondVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Varaibles<br>    var changeLAbelDelegate: ChangeLabelTextProtocol?<br>    var secondView: SecondView?<br>    var labelText:String = &quot;&quot;<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        prepareChangeLabelText()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>}<br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>        changeLAbelDelegate = secondView<br>        changeLAbelDelegate?.changeLabelText(text: labelText)<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>}</pre><p>Here changeLabelDelegate will be our employee, our deputy, our governor and we tell him in the prepareChangeLabelText method that you are actually the secondView because it is easier to access the label in the secondView and we created our function there.</p><p>Immediately after making the delegation assignment, we call the changeLabelText function via delegation, that is, we run the changeLabelText function in the SecondView, then it processes the labelText value we give it to the text value of the secondLabel.</p><p>And as soon as the screen appears 🎉. the value we wrote in firstTextFielda appears on the screen.</p><p>Yes, I am very, very, very, very long and this is definitely not the best practice of this process, but I thought that the more complicated it gets and the better I can explain this complexity, the better it will sit with you, so I took this long and I followed a roundabout way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*pVMJyyRARaNYxOTxXIcgIQ.gif" /><figcaption>We can move our text value.</figcaption></figure><h4>Step 3 Click on secondButton and go back</h4><p>I think I don’t need to explain this either, I think you will see and understand what we are already doing.</p><p>I put all the codes at the bottom with the unnecessary parts cut off, if it does not come to your mind because I give the codes cut off and at different times.</p><p>And if you want to download and look at it, here is my GitHub link if you want to download and look at it, I’ll take a star, your applause and your follow 😂</p><p><a href="https://github.com/yasinozmeen/ProtocolDelegationPattern.git">GitHub - yasinozmeen/ProtocolDelegationPattern</a></p><p><a href="https://twitter.com/yasinozmeen">Follow me on Twitter, I’m constantly sharing articles that I find at least as good(!) as my own 🥳</a></p><pre>final class FirstView: UIView {<br>    // MARK: - Varaibles<br>    weak var buttonTapDelegate: ButtonTapProtocol?<br>    <br>    // MARK: - UI Elements<br>    private let firstLabel: UILabel = {...}()<br>    private let firstTF: UITextField = {...}()<br>    private let firstButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    private func configure() {<br>        backgroundColor = .systemGray5<br>        setupFirstLabel()<br>        setupFirstTf()<br>        setupFirstButton()<br>    }<br>    <br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>        buttonTapDelegate?.didTapButton(text: firstTF.text)<br>    }<br>    <br>}<br>// MARK: - UI Configure Function With SnapKit<br>extension FirstView {<br>...<br>}</pre><pre>protocol ButtonTapProtocol: AnyObject {<br>    func didTapButton(text: String?)<br>}<br>final class FirstVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Properties<br>    let secondVC = SecondVC()<br>    var firstView: FirstView?<br>    var secondVCDelegate: PrepareChangeLabelNameProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>        delegateImplemantent()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>    <br>    private func delegateImplemantent() {<br>        firstView?.buttonTapDelegate = self<br>        secondVCDelegate = secondVC<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        secondVCDelegate?.getText(text: text) {<br>            navigationController?.pushViewController(secondVC, animated: true)<br>        }<br>    }<br>}</pre><pre>protocol ChangeLabelTextProtocol:AnyObject {<br>    func changeLabelText(text:String)<br>}<br>class SecondView: UIView,ChangeLabelTextProtocol {<br>    let secondVC = SecondVC()<br>    weak var buttonTapDelegate: ButtonTapProtocol?<br>    <br>    // MARK: - UI Elements<br>    private var secondLabel: UILabel = {...}()<br>    private let secondButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configure() {<br>        backgroundColor = .systemGray5<br>        setupSecondLabel()<br>        setupSecondButton()<br>    }<br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>        buttonTapDelegate?.didTapButton(text: nil)<br>    }<br>    func changeLabelText(text: String) {<br>        secondLabel.text = text<br>    }<br>}<br>// MARK: - UI Configure Function With SnapKit<br>extension SecondView {<br>...<br>}</pre><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>    func getText(text: String?, handler: (()-&gt;()))<br>    func prepareChangeLabelText()<br>}<br>class SecondVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Varaibles<br>    var changeLAbelDelegate: ChangeLabelTextProtocol?<br>    var secondView: SecondView?<br>    var labelText:String = &quot;&quot;<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        delegateImplemantent()<br>        prepareChangeLabelText()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>    <br>    func delegateImplemantent(){<br>        secondView?.buttonTapDelegate = self<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        navigationController?.popViewController(animated: true)<br>    }<br>}<br><br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>        changeLAbelDelegate = secondView<br>        changeLAbelDelegate?.changeLabelText(text: labelText)<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfc4379ad19e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 Ayda(!) Mid Olmak İsteyen Jr.lar için: Swift Delegation Pattern]]></title>
            <link>https://yasinozmeen.medium.com/6-ayda-mid-olmak-i%CC%87steyen-jr-lar-i%C3%A7in-swift-delegation-pattern-e890f8fba6d6?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/e890f8fba6d6</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-programming]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Thu, 15 Jun 2023 20:14:57 GMT</pubDate>
            <atom:updated>2023-06-16T12:08:08.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HjdURIP22Jv-47vw" /><figcaption>Photo by <a href="https://unsplash.com/@claybanks?utm_source=medium&amp;utm_medium=referral">Clay Banks</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Merhaba ve hoşgeldiniz arkadaşlar bu yazımda Delegation Patterni kendi anladığım şekilde anlatmayı düşünüyorum çünkü çoğu yerde aynı şekilde anlatılıyor. İşte bir araç protocolu varmış ve gitmiş araba bu araç protocolunu kendine tanımladığı için sürme yetisi gelmiş vs vs bunlar zaten tamamen syntaxlık işler zor olan bence bu değil, zor olan gerçek uygulamada bunu nerede kullanıcağımızı bilemememiz. Buda hep ezberden oluyor işte. Bu yazımda size Delegation Patternin mantığını anlatmayı amaçlıyorum.</h4><h3>Çayınızı kahvenizi alın uzun bir yazı sizi bekliyor ☕️</h3><blockquote>eğer bir noktada sıkılır veya yanlış görürseniz lütfen geri bildirimde bulunun.</blockquote><p>Baslamadan önce eğer Protocol ve Clouser terimlerini daha önce duymadıysanız ve görünce korkup kapatıcaksınız sizi böyle alayım.👇🏼</p><blockquote><a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/closures/">Swift Book Resmi dökümantasyon Clouse anlatımı</a><br><a href="https://www.youtube.com/watch?v=AfM8FeQr2LI">- Closures / Swift ile iOS Programlama — Uğur KILIÇ</a><br><a href="https://www.youtube.com/watch?v=ND44vQ5iJyc">- Swift Closures Explained — Sean Allen</a></blockquote><blockquote><a href="https://medium.com/turkishkit/swift-4-protocols-giri%C5%9F-1dabc75a0ff7">- Protocols: Giriş — Ufuk KÖŞKER</a><br><a href="https://medium.com/turkishkit/swift-ile-protokol-tabanl%C4%B1-programla-protocols-2-b84b9dc091f9">-Protocols: İleri Seviye — Ufuk KÖŞKER</a></blockquote><h4>Gerçek Uygulamalardan gitmek istediğimi söylemiştim o yüzden hadi 2 ekranlı veri aktarımı yaptığımız bir app tasarlayalım.</h4><p><em>View kısımlarını hızlıca geçiyorum</em></p><pre>class SceneDelegate: UIResponder, UIWindowSceneDelegate {<br>    <br>    var window: UIWindow?<br>    // MARK: - UI Scene Caller<br>    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, <br>               options connectionOptions: UIScene.ConnectionOptions) {<br>        guard let windowScene = (scene as? UIWindowScene) else {return}<br>        let window = UIWindow(windowScene: windowScene)<br>        let FirstVC = FirstVC()<br>        let navController = UINavigationController(rootViewController: FirstVC)<br>        window.rootViewController = navController<br>        self.window = window<br>        self.window?.makeKeyAndVisible()<br>    }<br>}<br>/// Burada uygulamamızı FirstVC&#39;yi gorünüm denetleyicisi seçmiş bir<br>/// Navigation Controllerdan başlatacağımızı söylüyoruz basitçe.</pre><pre>final class FirstView: UIView {<br>    // MARK: - UI Elements<br>    private let firstLabel: UILabel = {...}()<br>    private let firstTF: UITextField = {...}()<br>    private let firstButton: UIButton = {...}()<br>    /// Label, TextField ve Buttonu Clouser içinde özelleştiriyorum. <br><br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    private func configure() {<br>        backgroundColor = .systemGray5<br>        setupFirstLabel()/// Bu üç fonksiyonu bir extensiyon ile oluşturdum<br>        setupFirstTf()/// ve snapkit ile ekrana hizaladım<br>        setupFirstButton()/// konumuz olmadıgı için doldurmuyorum ekranı. <br>    }<br>    <br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>    }<br>    // bu fonksiyon butonumuza tıklanınca çalışacak olan fonksiyon<br>}</pre><blockquote>Eğer programatik ui oluşturmak istiyorsanız bu kaynakları öneriririm<br><a href="https://www.youtube.com/@Codebrah/about">- Çok güzel videoları olan yabancı bir abimiz</a><br><a href="https://www.youtube.com/playlist?list=PLy1rmeMw1yu9Anv6SPdhhBAtsZ9eq3o-h">- Hem Nasıl yapılacağını anlatması hemde püf noklardan bahsetmesi açısından güzel bir playlist</a><br><a href="https://medium.com/@burrakerden/what-is-snapkit-and-how-to-use-it-with-brief-descriptions-d6af19b3c4bc">- Programatik ui öğrendikten sonra öğreneceğiniz ilk Şey <strong>SnapKit</strong>, asla standart <strong>Constraints</strong> ile zaman kaybetmeyin</a></blockquote><pre>final class FirstVC: UIViewController{<br>    // MARK: - Properties<br>    var firstView: FirstView?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>}<br><br></pre><p>Ekran ilk açılınca gösterilecek olan VC’nin viewvini bizim tasarladığımız viewe eşitliyoruz. Peki neden firstView’i ilk olarak optinal bir değer olarak yapıyoruz ? Ekranda gösterilecek olan View i firstView e eşitlediğimiz için ViewControllerın hayatı bittiği zaman Ekranda gösterdiğimiz Viewinde hayatı bitmeli ki ekranda yeni bir şey gösterebilelim o yüzden bu şekilde bir değişken olarak tanımlayıp sonra Viewe eşitliyoruz.</p><pre>class SecondView: UIView{<br>    // MARK: - UI Elements<br>    private var secondLabel: UILabel = {...}()<br>    private let secondButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configure() {<br>        backgroundColor = .systemGray5<br>        setupSecondLabel()//Bu fonksıyonlarda SnapKit kullanarak<br>        setupSecondButton()//Elementlerı ekrana yerlestırmeye yarıyorlar<br>    }<br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>    }<br>///Bu view de FirstView ile aynı mantıkda elementlerimizi tanımlıyoruz ve<br>///Init anında bu elementleri configure ediyoruz. </pre><pre>class SecondVC: UIViewController{<br>    // MARK: - Varaibles<br>    var secondView: SecondView?<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>}// Buradaki her şey de FirstVC ile aynı o yüzden devam ediyorum. </pre><figure><img alt="Evet Viewlerimizi ve ViewControllerlarımızı tanımladık uygulama şu anda şöyle gözüküyor." src="https://cdn-images-1.medium.com/max/1024/1*Jn3KmlQm1w3GrPZywMRhZQ.png" /><figcaption>Evet Viewlerimizi ve ViewControllerlarımızı tanımladık uygulama şu anda şöyle gözüküyor.</figcaption></figure><h4>Şimdi bu işlemler bittikten sonra ilk yapmamız gereken şey biz ne istiyoruz, hangi yol ile istediğim şeyi yaparsak daha kolay olur.</h4><ol><li>FirstVC deki Butona tıkladığım zaman SecondVC’ye gitmek</li><li>firstTextFieldaki yazının secondLabel da yazılması</li><li>secondButton’a tıklandığı zaman FirstVC’ye gitmek</li></ol><p>Şimki sıra sıra isteklerimizi yerine getirelim.</p><p>Öncelikle bir Protocol yazalım ve ismi ButtonTapProtocol olsun ve AnyObject olarak işaretleyelim çünkü bu protocolü sadece sınıfların benimsemesini istiyoruz. <br> Ayrıca 1.maddede istediğimiz görevi yerine getirecek bir fonksiyon tanımlayalım protocolümüzün içine</p><pre>protocol ButtonTapProtocol: AnyObject {<br>    func didTapButton()<br>}</pre><blockquote>Bütün bu tanımlamanın nerede yapıldığının hiç bir önemi yok çok büyük bir app yapıyorsanız ve delegate pattern kullanıyorsanız sırf <br>protocoller için ayrı bir swift dosyası açıp hepsini orada bile tutabilirsiniz. Protocoller de standart sınıflar ve structlar gibi her yerden çağırılabiliyor</blockquote><p>Şimdi FirstViewimize gidelim çünkü butona tıklandığı zaman ilk uyarılan fonksiyonumuz orada.</p><p>Bir Nesneyi-Değişkeni eğerki protocol cinsinden oluşturursak o değişken bizim protocolün fonksiyonlarına/içeriğine erişmemize olanak sağlar. <br>Nasıl yani? Böyle ⬇️</p><pre>weak var buttonTapDelegate: ButtonTapProtocol?</pre><p><a href="https://developer.apple.com/forums/thread/692158#:~:text=The%20Swift%20book%20says%20that,are%20declared%20as%20weak%20references.%22"><em>weak ne ayak derseniz buraya bakabilirsiniz</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onwPm49hSwxTbL5Me0sTvA.png" /></figure><p>Biz de bu sayede Butona tıklanınca çalışan buttonTapped() fonksiyonunun içinde protocolümüzdeki didTapButton fonksiyonunu çağıracağız. Neden orada çağırıyoruz?<br>Çünkü didTapButton Foksiyonunun Butona tıklandıktan sonra <br>çalışmasını / çağrılmasını istiyoruz. buttonTapped() fonksiyonunun son hali bu şekilde</p><pre>@objc func buttonTapped(){<br>    buttonTapDelegate?.didTapButton()<br>}</pre><p>Peki şimdi butona tıklanınca didTapButton çalışacak tamam ama nasıl çalışacak bu fonksiyonun içeriğini tanımlamadık ki ?? <br>Aynen öyle bu fonksiyonun içeriğini tanımlamadık ayrıca hatırlarsınız ki<br>Delegatimiz daha nil, onu optional olarak tanımlamıştık.<br>Sıra geldi delegatimizin anlamını doldurmaya yani onu. Temsilci, vekil yapmaya.</p><p>Şimdi FirstVC’ye gidelim ve delegateImpemantent adında bir fonksiyon oluşturalım. <br>Oluşturalım oluşturalım ama niye oluşturalım?<br>Yukarıda da dediğim gibi firstView sayfamızdaki buttonTapDelegate şu anda nil durumda ve onu altını doldurmalıyız, eğer Delegate kelimesinin türkçe anlamıyla anlatmak gerekirse ona bir vekil, temsilci, sorumlu kişi vermeliyiz.</p><pre>private func delegateImplemantent() {<br>    firstView?.buttonTapDelegate = self<br>}</pre><blockquote>Ben bu kısmı kafamda tam anlamıyla oturttuktan sonra bazı seylerı anlamak benim için daha kolaydı o yüzden burada biraz zaman geçirebiliriz.</blockquote><p>firstView.buttonTapDelegate = self derken ne diyoruz tane tane gidelim. <br>Öncelikle firstView dediğimiz zaman zaten bizim view sınıfımızdan bahsettiğini biliyoruz ve diyoruz ki firstView içindeki buttonTapDelegate değişkeni ben olmak istiyorum. <br>Hmm nasıl yani ben olmak istiyorum ?<br>Değişken değil de temsilci diyelim o zaman daha iyi oluyor. <br>Bak şimdi firstView sınıfında buttonTapDelegate temsilcisi ben olmak istiyorum. YanibuttonTapDelegate aslında bizim FirstVC miz ama biz buttonTapDelegate’i ButtonTapProtocol’den türettiğimiz için FirstVC Bizim ButtonTapProtocol ile ilgili olan işlerimizden sorumlu olacak.</p><p>Yani biz butona tıkladığımızda didTapButton fonksiyonunun çalışması gerekiyordu ya işte bu çalışma/çalıştırma görevini FirstVC ben üsteliyorum dedi. E tamam üstlensin ama nasıl üstlenecek onda bu fonksiyon yok, çok doğru zaten ben bunları demeye kalmadan Xcode❤️ bana kızdı ve böyle diyor ⬇️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5mx_dzNmXu41Ir80ZZnnA.png" /></figure><p>Yani çevirmek gerekirse diyor ki ⬇️</p><blockquote>Sen buttonTapDelegatei buraya atamazsın çünkü o bir ButtonTapProtocol görevlisi, temsilcisi, çalışanı istiyor. Ama eğer sende kendine ButtonTapProtocol eşlersen ve gerekli fonksiyonları kullanırsan, temsilci sen olabilirsin.</blockquote><p>E süper bizimde istediğimiz buydu zaten diyoruz ve gerekli işlemleri yapıyoruz.</p><pre>final class FirstVC: UIViewController, ButtonTapProtocol {<br>...<br>private func delegateImplemantent() {<br>    firstView?.buttonTapDelegate = self<br>}<br>func didTapButton() {<br><br>}<br>...<br>}</pre><p>Yukarıda da gördüğümüz gibi FirstVC sınıfımıza Protocolü işliyoruz ve ardından gerekli fonksiyonları edindikten sonra Xcode bize kızmayı bırakıyor ve Artık tescilli olarak FirstView’in bir Temsilcisi, çalışanı, görevlisi olmuş oluyoruz.</p><p><em>Hani o </em><em>firstButtona tıklandığı zaman çalışan </em><em>didTapButton vardı ya işte biz artık </em><em>buttonTapDelegate olduğumuz için ve </em><em>didTapButton fonksiyonuna da bizim sayemizde ulaşıldığı için artık o fonksiyon </em><em>FirstVC içindeki </em><em>didTapButton fonksiyonunun ta kendisiymiş gibi düşünebiliriz.</em></p><p>Şimdi 1. Maddemizi gerçekleştirebiliriz. firstButton’a tıklandığı zaman SecondVC’ye gitmek için aşağıdaki işlemleri yapmamız yeterli oluyor.</p><pre>func didTapButton() {<br>   navigationController?.pushViewController(secondVC, animated: true)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*lnxF1Wn4WIkJooaw_VoztA.gif" /><figcaption>Ekran geçişimizi sağladık</figcaption></figure><h3>Şimdi sıra geldi 2. Maddeyi gerçekleştirmeye.</h3><blockquote>firstTextField’a girilmiş text değerini secondLabel da göstermek.</blockquote><p>1.Maddeden hatırladıklarımızla neler yapmamız gerektiğini düşünelim şimdi.</p><ul><li>Girilen text değerini almalıyız.</li><li>Text değerini bir yerde tutmalıyız.</li><li>Diğer ekran yüklenmeden önce bu text değerini secondLabel&#39;da göstermeliyiz</li></ul><p>Girilen text değerini almak için zaten textin girildiği yerde çalışan bir fonksiyonumuz var didTapButton, Bu fonksiyonu String bir deger isteyecek sekilde bir parametre ekleyelim.</p><pre>func didTapButton(text: String?) {<br>  navigationController?.pushViewController(secondVC, animated: true)<br>}</pre><p>Optional yapalım çünkü belki ileride başka şekillerde kullanılmak ister ve text değerini nil olarak girebilelim. 😉</p><p>Tamam şimdi text değerini alabiliyoruz bir diğer adım bu değeri SecondVC’de bir yerde tutmak ve göstermek için çalışması gereken diğer fonksiyonların çalışmasını beklemek. Eğer beklememiz gerekiyorsa biz yazıyı getirme işlemini ikinci ekrana gittikten sonra yapamayız, ekranımız gösterilmeden, ekranda ne yazacağını ekrana söylemiş olmamız lazım o zaman önce yazıyı götürelim, yazıyı depolayalım ve ne yazacağını söyleyelim sonra ekrana gidelim.</p><p>Bunları yapmak içinde bize protocol ve yeni bir temsilci lazım. Hadi bunları nerelerde yapmamız gerektiğini düşünelim.</p><ul><li>Dediğimiz gibi Protocolün nerede tanımlandığının bir önemi yoktu o yüzden onu istediğimiz yerde oluşturabiliriz ve ismi de PrepareChangeLabelNameProtocol olsun. Hazırlamak diyorum çünkü önce texti bir yerde tutmalı ve secondView i hazırlamalıyız</li></ul><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>}</pre><ul><li>Peki Protocolümüzün fonksiyonları neler olmalı, düşünelim ne yapmak istiyoruz. <br>Yazıyı getirmek, depolamak ve göstermek içinSecondView’i hazırlamak istiyoruz. O zaman fonksiyonlarımız şu şekilde olmalı. ⬇️</li></ul><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>    func getText(text: String?, handler: (()-&gt;()))<br>    func prepareChangeLabelText()<br>}</pre><ul><li>getText Fonksiyonunda bir completion handler var çünkü once yazıyı getirip kaydetmek ardından 2. ekranı görmek istiyorum.</li><li>Sırasıyla fonksiyonlarımızı yerleştirelim ve oluşturalım. Düzen sağlamak adına bir extension yazacağım.</li></ul><pre>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>    }<br>    <br>}</pre><ul><li>SecondVC’nin üst tarafındagetText Fonksisyonu çalıştığı zaman aldığı değeri depolayabileceği bir String değişkeni oluşturalım ve ardından getText fonksiyonunun içini dolduralım.</li></ul><pre>class SecondVC: UIViewController{<br>    // MARK: - Varaibles<br>    var labelText:String = &quot;&quot;<br>    ...<br>}<br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>    <br>}</pre><p>getText metodumuz labelText değişkenimize paremetresinde aldığı text değerini atadıktan sonra handlerda yazılmış değerleri çalıştırmaya gidiyor. Peki bu paremetreyi ve handlerı nerde alıyoruz tabiki de kendimize en uygun yerde ve bu şimdi bizim senaryomuz için FirstVC deki didTapButton fonksiyonun içi oluyor çünkü didTapButton fonksiyonumuz hem text paremetresini istiyor hem de SecondVC ye gitmeden önceki son fonksiyonumuz. Ama önce getText fonksiyonunu orda kullanabilmek icin bir delegate islemi yapmamız lazım bunu zaten 2 kere yaptığımız için artık detaylı anlatmıyorum sınıfımızın son halı bu şekilde ⬇️</p><pre>final class FirstVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Properties<br>    let secondVC = SecondVC()<br>    var firstView: FirstView?<br>    var secondVCDelegate: PrepareChangeLabelNameProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>        delegateImplemantent()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>    <br>    private func delegateImplemantent() {<br>        firstView?.buttonTapDelegate = self<br>        secondVCDelegate = secondVC<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        secondVCDelegate?.getText(text: text){<br>            navigationController?.pushViewController(secondVC, animated: true)<br>        }<br>    }<br>}</pre><p>didTapButton methodumuzu da güncelledim ve secondVCDelegate ile eriştiğimiz getText metoduna firstTextField’dan aldığımız text değerini veriyoruz aynen.</p><p>Artık getText metodumuz biz butona bastığımız zaman çalışıyor ve text field a girdiğimiz değeri labelText değişkenine atıyor.</p><p>Şimdi sırada LabelText değişkenindeki değeri secondLabel da göstermek. Bunu ayarlamak için viewWillAppear metodumuzu kullanıcaz çünkü ekran görünmeden hazırlıklarımızı yapmak istiyoruz ayrıca viewWillAppear ekran her görünmeden önce çalışır.</p><p>SecondView’a bir protocol yapıyoruz bu da asıl işimizi, labelın değerini değiştirecek olan metodu barındırıcak ve bu metodu delegate yöntemiyle SecondVC nin viewWillAppear methodunda erişeceğiz ve istediğimiz gibi daha ekran görünmeden label hazırlanmış olacak.</p><pre>protocol ChangeLabelTextProtocol:AnyObject {<br>    func changeLabelText(text:String)<br>}<br>class SecondView: UIView,ChangeLabelTextProtocol {<br>    ......<br><br>    func changeLabelText(text: String) {<br>        secondLabel.text = text<br>    }<br>}</pre><p>Tammamm şimdi delegasyon atamalarımızı yapmamız lazım</p><pre>class SecondVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Varaibles<br>    var changeLAbelDelegate: ChangeLabelTextProtocol?<br>    var secondView: SecondView?<br>    var labelText:String = &quot;&quot;<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        prepareChangeLabelText()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>}<br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>        changeLAbelDelegate = secondView<br>        changeLAbelDelegate?.changeLabelText(text: labelText)<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>    <br>}</pre><p>Burda changeLabelDelegate bizim çalışanımız, yardımcımız, valimiz olacak ve biz ona prepareChangeLabelText metodunun içinde sen aslında secondViewsin diyorsuz çünkü labela erişim secondView’da daha kolay ve fonksiyonumuzu orada oluşturduk</p><p>Delegasyon atamasını yaptıktan hemen sonra delegasyon üzrinden changeLabelText fonksiyonunu çağırıyoruz yani SecondViewdaki changeLabelText fonksiyonunu çalıştırıyoruz ardından secondLabelın text değerine ona verdiğimiz labelText değerini işliyor.</p><p>Ve ekran göründüğü anda 🎉. firstTextFielda yazdığımız değer ekranda görünüyor.</p><p>Evet ben çok çok çok uzattım ve kesinlikle bu yaptığımız işlemin best practicesi bu değil ama iş ne kadar karmaşıklaşırsa ve bu karmaşıklığı ne kadar iyi anlatabilirsem sizde daha iyi oturacağını düşündüm bu yüzden bu kadar uzattım ve dolangaçlı biz yol izledim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*pVMJyyRARaNYxOTxXIcgIQ.gif" /><figcaption>Yazımızı taşıyabiliyoruz</figcaption></figure><h4>3. Aşama secondButton’a tıklayınca geri dönmek</h4><p>Bunu da anlatmama gerek yoktur diye düşünüyorum görüp zaten ne yaptığımız anlarsınız.</p><p>Kodlari kesik kesik ve farklı zamanlarda verdiğim için kafanızda canlanmamışsa eğer bütün kodları en aşşağıya gereksiz yerleri kesilmiş şekilde koyuyorum.</p><p>Ve eğer indirip bakmak isteseniz GitHub linkim burada bir yıldızınızı alkışınızı ve takipinizi alırım 😂</p><p><a href="https://github.com/yasinozmeen/ProtocolDelegationPattern.git">GitHub - yasinozmeen/ProtocolDelegationPattern</a></p><p><a href="https://twitter.com/yasinozmeen">Twitterdan takip edin, en az kendiminki kadar(!) güzel gördüğüm makaleleri sürekli paylaşıyorum </a>🥳</p><pre>final class FirstView: UIView {<br>    // MARK: - Varaibles<br>    weak var buttonTapDelegate: ButtonTapProtocol?<br>    <br>    // MARK: - UI Elements<br>    private let firstLabel: UILabel = {...}()<br>    private let firstTF: UITextField = {...}()<br>    private let firstButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    private func configure() {<br>        backgroundColor = .systemGray5<br>        setupFirstLabel()<br>        setupFirstTf()<br>        setupFirstButton()<br>    }<br>    <br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>        buttonTapDelegate?.didTapButton(text: firstTF.text)<br>    }<br>    <br>}<br>// MARK: - UI Configure Function With SnapKit<br>extension FirstView {<br>...<br>}<br><br></pre><pre>protocol ButtonTapProtocol: AnyObject {<br>    func didTapButton(text: String?)<br>}<br>final class FirstVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Properties<br>    let secondVC = SecondVC()<br>    var firstView: FirstView?<br>    var secondVCDelegate: PrepareChangeLabelNameProtocol?<br>    <br>    // MARK: - Life Cycle<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        configureUI()<br>        delegateImplemantent()<br>    }<br>    <br>    // MARK: - Functions<br>    private func configureUI() {<br>        firstView = FirstView()<br>        self.view = firstView<br>    }<br>    <br>    private func delegateImplemantent() {<br>        firstView?.buttonTapDelegate = self<br>        secondVCDelegate = secondVC<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        secondVCDelegate?.getText(text: text) {<br>            navigationController?.pushViewController(secondVC, animated: true)<br>        }<br>    }<br>}</pre><pre>protocol ChangeLabelTextProtocol:AnyObject {<br>    func changeLabelText(text:String)<br>}<br>class SecondView: UIView,ChangeLabelTextProtocol {<br>    let secondVC = SecondVC()<br>    weak var buttonTapDelegate: ButtonTapProtocol?<br>    <br>    // MARK: - UI Elements<br>    private var secondLabel: UILabel = {...}()<br>    private let secondButton: UIButton = {...}()<br>    <br>    // MARK: - Life Clycle<br>    override init(frame: CGRect) {<br>        super.init(frame: frame)<br>        configure()<br>    }<br>    <br>    required init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Function<br>    func configure() {<br>        backgroundColor = .systemGray5<br>        setupSecondLabel()<br>        setupSecondButton()<br>    }<br>    // MARK: - Action<br>    @objc func buttonTapped(){<br>        buttonTapDelegate?.didTapButton(text: nil)<br>    }<br>    func changeLabelText(text: String) {<br>        secondLabel.text = text<br>    }<br>}<br>// MARK: - UI Configure Function With SnapKit<br>extension SecondView {<br>...<br>}</pre><pre>protocol PrepareChangeLabelNameProtocol: AnyObject {<br>    func getText(text: String?, handler: (()-&gt;()))<br>    func prepareChangeLabelText()<br>}<br>class SecondVC: UIViewController, ButtonTapProtocol {<br>    // MARK: - Varaibles<br>    var changeLAbelDelegate: ChangeLabelTextProtocol?<br>    var secondView: SecondView?<br>    var labelText:String = &quot;&quot;<br>    <br>    // MARK: - Life Cycle<br>    override func viewWillAppear(_ animated: Bool) {<br>        super.viewWillAppear(animated)<br>        configureUI()<br>        delegateImplemantent()<br>        prepareChangeLabelText()<br>    }<br>    <br>    // MARK: - Functions<br>    func configureUI() {<br>        navigationItem.hidesBackButton = true<br>        secondView = SecondView()<br>        view = secondView<br>    }<br>    <br>    func delegateImplemantent(){<br>        secondView?.buttonTapDelegate = self<br>    }<br>    <br>    func didTapButton(text: String?) {<br>        navigationController?.popViewController(animated: true)<br>    }<br>}<br><br>extension SecondVC: PrepareChangeLabelNameProtocol{<br>    <br>    func prepareChangeLabelText() {<br>        changeLAbelDelegate = secondView<br>        changeLAbelDelegate?.changeLabelText(text: labelText)<br>    }<br>    <br>    func getText(text: String?, handler: (()-&gt;())){<br>        if let text = text{<br>            self.labelText = text<br>            handler()<br>        }<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e890f8fba6d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100days-seventeenthDay-Simple present tense]]></title>
            <link>https://yasinozmeen.medium.com/first100days-seventeenthday-simple-present-tense-6f4e313713bb?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f4e313713bb</guid>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <category><![CDATA[100daychallenge]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 21:49:03 GMT</pubDate>
            <atom:updated>2022-02-04T21:49:03.563Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba arkadaşlar bugün geniş zaman konusuna değineceğiz ve yazımızın sonunda ufak bi konuşma gerçekleştireceğiz bu yazı ile ilgili.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WcV_cwsw5t19O16b" /><figcaption>Photo by <a href="https://unsplash.com/@federicorespini?utm_source=medium&amp;utm_medium=referral">Federico Respini</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>En çok kuralı olan ve en zor zaman buymuş öyle dedi özer hocam bu arada özer hoca kim diye soranlar olursa onların daha önceki yazılarımı okumadığını anlarım ve bu ingilizce çalışma notlarımın kaynağının <a href="https://www.youtube.com/playlist?list=PLp9-shPIqO8OnxLVnrfl_47QRkE0yRLyi">bu linkteki playlist</a> olduğunu belirtmek isterim ayrıca özer hocanın çeviri ile öğren kitabınada sahibim ve çok yararlı olduğunu söylemek istiyorum videolar ile eş zamanlı götürünce çok güzel oluyor. Konumuza geri dönelim.</p><p>Geniş zaman yapar, eder, gider, gelir şeklindeki cümleler kurduğumuz bir zaman dilimi. Bu kısa notu da vererek şimdi asıl konuya girişiyoruz cümle yapıları üzerinden gidicez olumlu cümle ile başlayalım.</p><h4>Olumlu cümle</h4><p>I öznesi tekil olmasına rağmen çoğulmuş gibi kullanılıyor kuralda onların grubunda yani ama “ben” yine tek kişi onda bir sorun yok kafamız karışmasın sakun. Cümlemizin en başında özne sonrasında to be(am/is/are) gelmeden fiiller geliyor. Tekil bir cümle kurduysak fiile -s takısı geliyor başka durumlarda gelmiyor bu arada “I” tekil ama çoğul gurubundaymış gibi davrandığımız için özne “I” ise fiile -s gelmez. Sonrasında nesne ve isteye bağlı yer zarfı gelebilir ardından da zaman zarfı ama “o şimdi yüzünü yıkar” cümlesi geniş zaman için biraz saçma bir zaman edatı kullanıyor, kullanılması daha hoş durabilen zaman zarflarına bir bakalım.</p><ul><li>every d<strong>ay →her gün</strong></li><li><strong>every week →her hafta</strong></li><li><strong>every month →her ay</strong></li><li><strong>at weekends →haftasonları</strong></li><li><strong>all the time →her zaman</strong></li><li><strong>in the evening →akşamları</strong></li><li><strong>once a week →haftada bir kez</strong></li><li><strong>once a year →yılda 1 kez</strong></li><li><strong>He cleans the house every day. →Evi her gün temizler.</strong></li><li><strong>She washes her car in the garage every week. →Arabasını her hafta garajda yıkar.</strong></li><li><strong>I eat a banana evey month. →Her ay bir muz yerim.</strong></li><li><strong>I know the answer all the time. →Cevabı her zaman bilirim.</strong></li><li><strong>You drinks lemonade in the garden in the evenings. →Akşamları bahçede limonata içiyorsun.</strong></li><li><strong>We play soccer at school once a week. →Haftada bir kez okulda futbol oynarız.</strong></li><li><strong>They dance in the prom once a year. →Onlar yılda bir kez baloda dans ediyorlar.</strong></li></ul><p>Geniş zamanda tüm zaman zarfları cümlenin sonuna gelmiyor, bazı zarflar fiilden hemen önce geliyor</p><ul><li><strong>Always(hep/her zaman), Usually(genellikle), Frequently(sıklıkla), Often(sıklıkla), Seldom(nadiren), Rarely(seyrek), Sometimes(bazen)</strong></li></ul><p>gibi, devrik cümle kurmak istersek zaman zarfını cümle başında da kullanabiliriz. Ayrıca zaman zarflarıın başına asla anlamına gelen “never” kelimesinide getirebiliriz tabi bu durumda cümlemiz olumsuz olur.</p><h4>Olumsuz cümle</h4><p>Geniş zamanın yardımcı fiili olan “do” ve “does” devreye giriyor burda ama tabiki cümle olumsuz olduğu için yanlarında “not” da var yani “do not”/”does not” ama tabiki böyle uzun kullanmıyoruz “don’t”/”doesn’t” diye kısaltıyoruz ve cümlenin tekil halinde kullandığımız “-s” takısı ortadan kalkıyor</p><h4>Soru cümlesi</h4><p>Do ve does özne ile yer değiştiriyor. Olumsuz soru sormak istersek “do”/ “does” yerine “doesn’t”/ “don’t” kullanmamız yeterli olur. <br>“Wh-” soru kelimeleri ile soru yapmak istersek bu kelimeleri soru cümlesinin en başına getirmemiz yeterlidir.</p><p>Olumlu cümlede do ve does kullanımında cümle farklı anlama sahip olur, vurgu yapmış oluruz bu durumda fiile s takısı getirmemize gerek kalmıyor (olumlu tekil durumda)</p><ul><li><strong>Ben ankarada yaşıyorum →I live in ankara</strong></li></ul><p>İngilizcede şimdiki zaman gerçekten o anda, konuşma anında gerçekleşen olayları konuşmada işimize yarıyor geniş zamanda bunun bir tık üstü işte.</p><ul><li><strong>Tom Almanca konuşur(bilir) →Tom speaks German</strong></li><li><strong>Tom Almanca konuşur →Tom is speaking German(o anda)</strong></li></ul><p>Daha önce have got, has got konusundayken bu kuralı İngilizlerin kullandığından ve Amerikanların başka kural kullandığından bahsetmiştik yani ben size bahsetmemişsem bile Özer hoca bana bahsetmişti işte şimdi geldik amerikanların kuralına.</p><p>Amerikan kullanımı ile have got has got</p><ul><li><strong>Onun bir köpeği var →She has a dog</strong></li><li><strong>Onun bşr köpeği yok →She doesn’t have a dog</strong></li><li><strong>Onun bir köpeği var mı →Does she have a dog</strong></li></ul><p>İngiliz kullanımı ile have got has got</p><ul><li><strong>She has got a dog →Onun bir köpeği var.</strong></li><li><strong>She hasn’t got a dog →Onun bir köpeği yok.</strong></li><li><strong>Has she got a dog →Onun köpeği var mı?</strong></li></ul><p>Evet bugünki konunun sonuna geldik, son kısımdaki have got has got çok kafa karıştırıcıydı hatta yazdıklarımdan pek bir şey anlaşılmıyor olabilir bile.</p><p>Artık çok fazla konu çalışmaya ve neredeyse hiç egzersiz, tekrar yapmamaya başladım normalde 20. günü beklemek istiyordum buralar çok önemli konular ve boş boş öğren geç öğren geç sonra hepsini bi çırpıda tekrar et çorba yap falan istemiyorum yani, bu yazı birkaç gün için son yazıydı en azından çeviri ile öğrende güncel yere kadar gelmeye çalışacağım ama bu müsaitlik durumumda yapabiliceğim birşey tabiki çünkü yarın kız arkadaşım ameliyat oluyor ve ertesi gün işe gitmem lazım yani ne zaman yazı gelir bilmiyorum bu süreci çok uzatmamaya çalışacağım o zamana kadar,</p><p>Kalın sağlıcakla👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f4e313713bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100Days-sixteenthDay-In, On, At]]></title>
            <link>https://yasinozmeen.medium.com/first100days-sixteenthday-in-on-at-108fb3c5cdc7?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/108fb3c5cdc7</guid>
            <category><![CDATA[100daychallenge]]></category>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Wed, 02 Feb 2022 20:59:09 GMT</pubDate>
            <atom:updated>2022-02-02T20:59:09.491Z</atom:updated>
            <content:encoded><![CDATA[<p>Biz daha önce in, on, at edatlarını yer edadı olarak kullanmıştık şimdi bu kelimeleri zaman edadı olarak kullanacağız. Hangi nerede nasıl kullanılır onlara bakacağız. Lafı hiç uzatmadan direk konuya geçelim</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x5P_46jjJdDbwda3" /><figcaption>Photo by <a href="https://unsplash.com/@davealmine?utm_source=medium&amp;utm_medium=referral">Dawid Zawiła</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>In kullanımı</h4><blockquote>Günün kısımlarında in kullanıyoruz yanına da the katıyoruz.</blockquote><ul><li><strong>In the morning →Sabahta</strong></li><li><strong>In the evening →Akşamda</strong></li><li><strong>In the afternoon →Öğleden sonrada</strong></li><li><strong>Müzik dersim sabahleyin →My music class is in the morning.</strong></li><li><strong>Akşamleyin yemek yiyebiliriz. →We can eating in the evening.</strong></li><li><strong>Öğleden sonra görüşebiliriz. →See you in the afternoon.</strong></li></ul><blockquote>Bunların dışında aylarda, mevsimlerde, yıllarda, yüzyıllarda da kullanabiliyoruz. Kısaca ay ve aydan uzun zaman dilimlerine kullanabiliriz.</blockquote><ul><li><strong>The meeting is in june →Toplantı haziran ayında</strong></li><li><strong>We are going to California in summer →Yazın Kaliforniya’ya gidiyoruz.</strong></li><li><strong>2019 yılında öğretmen olabilirim. →I can be a teacher in 2019.</strong></li></ul><h4>On kullanımı</h4><blockquote>Günlerde kullanılır, tarihi belirten kelimede “day” geçiyorsa kesin kullanılır.</blockquote><ul><li><strong>We can meet on Tuesday →Salı günü buluşabiliriz.</strong></li><li><strong>Come to my party on my birthday. →Doğum günümde partime gel.</strong></li><li><strong>We are having a big party on Christmas day. →Noel günündebüyük bir parti veriyoruz.</strong></li></ul><blockquote>Gün belirtilen ileri tarihlerde de “on” kullanlır.</blockquote><ul><li><strong>My birthday is on the second of may. →Benim doğum günüm 2 mayısta.</strong></li><li><strong>My birthday is in may. →Doğum günüm mayısta.</strong></li><li><strong>Cumartesi sabahı pikniğe gidebiliriz. →We can go on picnic on Saturday morning.</strong></li><li><strong>Cumartesi akşamı onu ziyaret edebiliriz. →We can visiting on Friday evening.</strong></li></ul><h4>At kullanımı</h4><blockquote>Saatlerin başına, öğlen, gece, gece yarısı, resmi tatiller, yemek vakitlerinde kullanılır.</blockquote><ul><li><strong>At six o’clock →Saat altıda</strong></li><li><strong>At half past three →Saat üç buçukta</strong></li><li><strong>At eleven PM. → Saat onbir de</strong></li><li><strong>At noon →Öğlen</strong></li><li><strong>At night →Gece</strong></li><li><strong>At midnight →Gece yarısı</strong></li><li><strong>At Christmas →Noelde</strong></li><li><strong>At easter →Paskalyada</strong></li><li><strong>At ramadan →Ramazanda</strong></li><li><strong>At/on the weekend →Hafta sonunda</strong></li><li><strong>At breakfast →Kahvaltıda</strong></li><li><strong>At lunch →Öğle yemeğide</strong></li><li><strong>At dinner →Akşam yemeğinde</strong></li><li><strong>Be here at two o’clock. →Saat 2 de burda ol.</strong></li><li><strong>Be here in two hours. →İki saat içinde burda ol.</strong></li><li><strong>Please call me later, I’m at lunch →Lütfen beni sonra ara, öğle yemeğindeyim.</strong></li></ul><h4>Özetlemek gerekirse</h4><ul><li><strong>Günün kısımlarından bahsederken “in” →in the morning, in the evening, in the afternoon</strong></li><li><strong>Öğlen, Gece, Gece yarısında “at” →At noon, At night, At midnight</strong></li><li><strong>Ay ve daha uzun zaman dilimlerinde in →In February, In Winter, In 1996</strong></li><li><strong>Günlerde ve zamanı belirten kelimede “day” geçen cümlelerde “on” →On new year’s day, On Tuesday afternoon</strong></li><li><strong>Saatlerde, resmi tatillerde ve yemek vakitlerinde→At nine o’clock, At the weekend, At dinner</strong></li></ul><blockquote>Bir olayın zamanlamasını sıralamamız gerekirse kısa zaman diliminden uzun zaman dilimine doğru bir sıralama yapmamız gerekiyor.</blockquote><ul><li><strong>Salı günü sabah saat 9 da sınavım var. →I’ve got an exem at nine o’clock in the morning on tuesday.</strong></li></ul><blockquote>Belirtilen zaman kelimesinden önce “next, last, this, every…” gibi kelimeler varsa in, on, at edatlarını kullanmaya gerek yok.</blockquote><p>Bugünkü yazımız bu kadardı sanırım 19. günün yazısını yayınladıktan sonra yazıya birazcık ara verip egzersiz ve tekrar yapıcam, hem bu durumda 20. günün yazısında da ne kadar ilerlemiş olduğumu görebiliriz. O zaman kadar,</p><p>Kalın sağlıcakla👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=108fb3c5cdc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100Days-fifteenthDay-Present Continuous Tense]]></title>
            <link>https://yasinozmeen.medium.com/first100days-fifteenthday-present-continuous-tense-cbf06ab1afca?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbf06ab1afca</guid>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <category><![CDATA[100daychallenge]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 21:58:50 GMT</pubDate>
            <atom:updated>2022-02-01T21:58:50.228Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*RL0XkLOvTMyea8SH7msHbw.png" /></figure><p>İngilizcede 12 tane zaman varmış ve ingilizce derslerinde genellikle geniş zamandan başlatılıyormuş ama en zor zaman da oymuş o yüzden biz bugün şimdiki zamanı göreceğiz, örnek vermek gerekirse.</p><ul><li><strong>Ben okula gidiyorum.</strong></li><li><strong>O ödevini yapıyor.</strong></li><li><strong>Onlar akşam yemeği yiyor.</strong></li></ul><blockquote>Cümle yapısı kaba olarak şu şekilde</blockquote><ul><li><strong>Özne + Yardımcı fiil + Fiil-ing(-yor) + fiilin ne yaptığını belirten kelime.</strong></li><li><strong>I am going to school. → Ben okula gidiyorum.</strong></li><li><strong>He is doing his homework. →O ödevini yapıyor.</strong></li><li><strong>They are eating dinner. →Onlar akşam yemeği yiyorlar.</strong></li></ul><blockquote>Olumsuz yapalım</blockquote><ul><li><strong>I am not going to school. →Ben okula gitmiyorum.</strong></li><li><strong>He is not doing his homework. →O ödevini yapmıyor.</strong></li><li><strong>They aren’t eating dinner. → Onlar akşam yemeği yemiyorlar.</strong></li></ul><blockquote>Soru cümlesi kuralım</blockquote><ul><li><strong>Am i going to school ? →Okula gidiyor muyum ?</strong></li><li><strong>Is he doing his homework ? →Ödevini yapıyor mu?</strong></li><li><strong>Are they eating dinner? →Akşam yemeği yiyorlar mı?</strong></li></ul><blockquote>Olumsuz soru cümlesi kuralım</blockquote><ul><li><strong>Am i not going to school ?→ Okula gitmiyor muyum?</strong></li><li><strong>Isn’t he doing his homework ? →Ödevini yapmıyor mu?</strong></li><li><strong>Aren’t they eating dinner? →Akşam yemeği yemiyorlar mı?</strong></li></ul><blockquote>Wh- li soru cümleleri</blockquote><ul><li><strong>Why am i going to school. →Neden okula gidiyorum</strong></li><li><strong>Where is he doing his homework. →Ödevini nerede yapıyor?</strong></li><li><strong>When are they eating dinner. →Ne zaman akşam yemeği yiyorlar?</strong></li></ul><blockquote>Kelimemiz “e” ile bitiyorsa “-ing” getirirken o “e” yi kaldırıp “-ing” yi öyle getiriyoruz.<br>Birde şöyle bir kural varmış<br>Sit →Sitting, Run →Running<br>Sesiz + sesli + sessiz harf ile bitiyorsa sondaki sessizi ikiliyoruz, sanırım böyle dil bilgisi konusunda çok cahilim. Bu gibi kuralların ezber ile değil zamanla oturduğunda daha sağlıklı olucağını düşünüyorum. <br>Play kelimesinde “y” yi iki kere okumak zor olduğundan play kelimesinde bu kuralı yapmıyoruz aynı şekilde mix kelimesi içinde geçerli</blockquote><blockquote>Fiilimiz “ie” harfleri ile bitiyorsa bunu “ying” diye değiştiriyoruz</blockquote><ul><li><strong>lie →ling</strong></li><li><strong>die →dying</strong></li></ul><h4>Tüm zamanlar için geçerli birkaç bilgi</h4><p><strong>I’m studying at he library now. →Şimdi kütüphanede ders çalışıyorum.</strong><br>Zaman zarfları cümlenin hep sonuna gelir, devrik cümlelerde iş değişir tabi<br><strong>Now, I’m studying at library.</strong></p><p>Şimdiki zamanda sıklıkla kullanılan birkaç zaman zarfı</p><ul><li><strong><em>At the moment →şu anda</em></strong></li><li><strong><em>At this moment →şu anda</em></strong></li><li><strong><em>right now →tam şimdi</em></strong></li><li><strong><em>just now →tam şimdi</em></strong></li><li><strong><em>currently →şu anda</em></strong></li><li><strong><em>nowadays →bugünlerde</em></strong></li></ul><p>İngilizcede şimdiki zaman kullanılırken gerçekten o anda geçen cümeler şimdiki zamanda kullanılır. <strong>“Seni seviyorum”</strong> şimdiki zaman cümlesi değil. <strong>“I love you”</strong>, eğer öyle olsaydı <strong>“I am loving you.”</strong> olmalıydı.</p><p>Evet bugünün 2. yazısında şimdiki zaman konusunu işledik ben bayadır tekrar ve egzersiz yapmıyorum bir ara yazı yazmayı bırakıp birkaç gün tekrar ve egzersize telafuza çalışabilirim şimdiden bunu yazayım yazmadığım zaman içim bir kötü oluyor :)</p><p>Kalın sağlıcakla👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbf06ab1afca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100Days-fourteenthDay-Imperatives]]></title>
            <link>https://yasinozmeen.medium.com/first100days-forthday-imperatives-ec5fe5b4bc73?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec5fe5b4bc73</guid>
            <category><![CDATA[100daychallenge]]></category>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 10:39:16 GMT</pubDate>
            <atom:updated>2022-02-01T10:40:16.678Z</atom:updated>
            <content:encoded><![CDATA[<p>Merhaba arkadaşlar normalde bu yazı dünün yazısıydı ama ben bursaya döndüm ve konu çalıştığım halde yazıyı yazmaya zaman bulamadığım için bugün bu dahil 2 yazı gelecek. Bu yazımızın konusu ingilizcesi imperatives yani<em> türkçesi emir cümlesi anlamına geliyor sanırım. </em>Genel ismi emir cümlesi diye geçiyor ama talimat, tavsiye, uyarı ve rica cümleleri de kurabiliriz. Hadi başlayalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xvm6d7dVDBMvRiNG" /><figcaption>Photo by <a href="https://unsplash.com/@inayali?utm_source=medium&amp;utm_medium=referral">Ali Inay</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>To eğerki nesnenin başına gelirse <strong>(to + nesne) -e/-a</strong> yönelme takısı olduğunu öğrenmişti.<br>To eğerki fiilin başına gelirse <strong>(to+ fiil) -mek/-mak</strong> anlamı katar</p><ul><li><strong>to come → gelmek</strong></li><li><strong>to go → gitmek</strong></li><li><strong>to eat → yemek</strong></li><li><strong>to drink → içmek</strong></li></ul><p>Özne kullanmadan sadece fiil kullanarak da cümle kurabiliriz çünkü mantıken emirler karşımızdaki kişiye söylenir o yüzden özne zaten bellidir, Türkçede de durum bu şekilde zaten <strong>gel, git, ye, iç</strong> kelimeleri kendi başına cümle oluşturabilir.</p><ul><li><strong>Open the door. → Kapıyı aç.</strong></li><li><strong>Clean the room. → Odayı temizle.</strong></li><li><strong>Clean your room. → Oda<em>nı</em> temizle.<br></strong>Buradaki your aitlik belirtiyor.<em>(sanırım aitlik belirtiyor yani, türkçem çok kötü ama özne olmadığını anladınız siz)</em></li><li><strong>Do homework. →Ödev yap.</strong></li><li><strong>Take me to hospital. →Beni hastaneye götür.</strong><em>(take=almak,götürmek)</em></li><li><strong>Bring me an aspirin. →Bana bir aspirin getir.</strong></li></ul><p>Emir cümleleri adı üstünde emir içerdiği için kaba olabiliyor karşı tarafa daha nazikçe bir cümle yöneltmek isterseniz cümlenin başına<strong> “Please…” </strong>getirebilirsiniz, eğer hâla yeterli olmadığını düşünüyorsanız cümlenin sonuna <strong>“Olur mu?”</strong> anlamına gelen <strong>“….will you?”</strong> konulabilir.</p><ul><li><strong>Please put your book on the table. →Lütfen kitabını masaya koy.</strong></li></ul><p>Eğerki cümlemizi gerçekleştirdiğimiz ortamda muhattap olduğumu kişiden başkaları da varsa cümlenin başına özne getirilebilir.</p><ul><li><strong>You clean the room. →Sen odanı temizle.</strong></li><li><strong>You do your homework. →Sen ödevini yap.</strong></li><li><strong>You take me to hospital. →Sen beni hastaneye götür.</strong></li></ul><h4>Olumsuz emir cümleleri</h4><ul><li><strong>Don’t sleep here. →Burda uyuma.</strong></li><li><strong>Don’t be late. → Geç kalma.</strong></li><li><strong>Don’t shout at me. →Bana bağırma.</strong><em>(Burda gördüğümüz gibi “shout” dan sonra “at” ingilizcede bazı fiilerden sonra fiile özel ek gelebiliyor)</em></li><li><strong>Don’t shout. →Bağırma.</strong><em>(Bu cümlede fiilden sonra belirtilen bir şey olmadığı için ek gelmedi.)</em></li></ul><p>Eğerki olumsuzu bastırmak istiyorsak Do not kelimelerini ayırabiliriz. Never kelimesi de olumsuzluk kattığı için cümlenin başında direk “never” da kullanabiliriz</p><ul><li><strong>Do not sleep here. →Burda uyuma</strong></li><li><strong>Never be late. →Geç kalma.</strong></li><li><strong>Never shout at me. →Bana bağırma</strong></li></ul><p>Evet emir cümeleri de bu kadardı birkaç saat sonra 2. yazıyıda girerim o zamana kadar,</p><p>Sağlıcakla kalın👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec5fe5b4bc73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100Days-thirteenthDay-Object Pronouns]]></title>
            <link>https://yasinozmeen.medium.com/first100days-thirthday-object-pronouns-654ca6b820a4?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/654ca6b820a4</guid>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <category><![CDATA[100daychallenge]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 21:25:18 GMT</pubDate>
            <atom:updated>2022-01-28T21:29:47.377Z</atom:updated>
            <content:encoded><![CDATA[<p>Heeepinize merhaba arkadaşlar, saat 23:47 ve bugün şehir değiştirdim+ bi ton trafikte araba falan sürdüm aşırı yorgunum ama çok uzun zaman sonra olduğu için böyle enerjik bir giriş yapmak istedim öncelikle <a href="https://medium.com/@itsxobll">Bıraktığımı sananlar</a> olmuş gelip bize sallamışlar öyle bir şey yok. Tamamen final haftası diye ara verdim ve hiç yazıda yayınlayamadığım için belirtemedim ama bunu daha önceden söylemiştim zaten. Sınavlarım nası geçti Güzelce çalışıp yüksek puanlar aldım mı peki ? İşte burda soru var vizelere daha fazla çalışmıştım finalleri hiç umursamadım resmen deli cesareti ama dönemin başından biraz sonra dersleri dersten sonra tekrar etme alışkanlığı edindiğim için konularda günceldim ve çok konu çalışmadan sınavlara gidebildim ve orta-iyi sonuçlarla 1. dönemi sonlandırmış bulunmaktayım. <em>(nur topu gibi bir ff im var “soyut matematik”)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PLyXZ29E8WzxreP3" /><figcaption>Photo by <a href="https://unsplash.com/@antoine1003?utm_source=medium&amp;utm_medium=referral">Antoine Dautry</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Bu süreçte hiç ingilzce çalışmadım ama herzamanki gibi ingilizceye çok maruz kaldım, after effect ve premiere pro programlarına sardım ve bunlarla ilgili ingilizce içerikler çıkıyor süreki karşıma onaları izliyoerum yarım yamalak anlaıyorum anlamaya çalışıyorum vb vb ama hâlen hayatıma biraz daha ingilizce sokabilirmişim gibime geliyor, neyse. Bu anlat kısmını çok uzun tuttum çünkü dersde anlatıcak bir şey bulamadım. Benim türkçe de de aitlik ilgi nesne vb. dil bilgisi hiç yoktu bende şu anda olduğumuz yerlerde tam bu bilgilerin gerektiği yerler o yüzden bazı sıkıntılar çekmiyorum değil, mesela.</p><ul><li>Bizi bugün ziyaret edebilir misin? → Can you visiting us today ?</li></ul><p>Bunun böyle çevrildiğini refleksen biliyorum mesela ama neden biz yerine us koydum bilmiyorum bu tamamen içimden gelerek yaptığım bir şey sanırım dil bilgisi bilsem bu kısmı oturtmam daha kolay olucak eğerki ilerleyen süreçte zorlanırsam çok hızlı bir dilbilgisi özeti yapabilirim şimdi 3 örnek daha yazıp bu günki yazıyı bitiyorum.</p><ul><li>Beni arayabilir misin? → Can you call me ?</li><li>Seni şimdi arayamam. → I can’t call you now.</li><li>Onları tarif edebilir misin? → Can you describe him?</li><li>Can you open them? → Onları açabilir misin?</li></ul><p>Böylelikle 13. günü yazmış bulunmaktayız böyle neredeyse hiç ing değinmemiş olduğumuzu biliyorum ama hem bilgi vermek hemde bugünden başlamak istiyordum 1 gün daha ertelersem uzar diye koruyordum. Aşşağıya genel tabloları bırakıp kaçıyorum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lkjp4rT-fzsX1GJIHaMYw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=654ca6b820a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#first100days-twelfthDay-Possessive Pronouns]]></title>
            <link>https://yasinozmeen.medium.com/first100days-twelfthday-possessive-pronouns-7b3e4ec188a2?source=rss-15efb0b7efee------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b3e4ec188a2</guid>
            <category><![CDATA[100daychallenge]]></category>
            <category><![CDATA[i̇ngilizce-öğrenmek]]></category>
            <dc:creator><![CDATA[Yasin Özmen]]></dc:creator>
            <pubDate>Thu, 13 Jan 2022 20:57:15 GMT</pubDate>
            <atom:updated>2022-01-13T20:57:15.881Z</atom:updated>
            <content:encoded><![CDATA[<p>Herkese 12. yazıdan merhaba arkadaşlar baya baya ilerliyoruz 12 tane yazı yazmışız şimdiye kadar, bu sıralar yazılar çok kısa ve muhabbet çok az oluyor çünkü final haftam derslere çok fazla çalışıyorum bu yoğunluğu atlattıktan sonra eskisi gibi düzene girebilrim diye düşünüyorum daha fazla uzatmadan konuya geçelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t5EqccuElAEORKrp" /><figcaption>Photo by <a href="https://unsplash.com/@craftedbygc?utm_source=medium&amp;utm_medium=referral">Green Chameleon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>İyelik Zamirleri</h3><p>İyelik zamirleri ismin yerini tutar ve yanında isim kullanılmasına gerek kalmaz, nesne ve özne pozisyonunda kullanılabilir, sadece özne pozisyonunda kullanılırsa tablodaki ikinci anlamında kullanılırlar. Hayvanlara ve nesnelere yönelik iyelik zamirleri ingilizcede bulunmuyor “its” gibi kullanımlar yanlış.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pl8njaFPo-faZa7YT0I2Ng.png" /></figure><ul><li><strong>Benim arabam siyah. →Mine car is black.</strong></li><li><strong>Onunki nerede. →Where is his/hers.</strong></li></ul><h4>Zamirler nesne yerine geçtiğinde</h4><ul><li><strong>This car is mine. →Bu araba benim.</strong></li><li><strong>This is my car. →Bu benim arabam.</strong><br><em>(my kullanırken my dan sonra isim gelmesine dikkat etmeliyiz eğerki isim gelmiyorsa mine kullanmalıyız)</em></li></ul><blockquote>Ne zaman iyelik ne zaman aitlik sıfatı kullanıcağımıza kara vermek için önce cümlenin türkçesini düşünüp öyle karar vermeliyiz çünkü birbirlerine çok benziyorlar.</blockquote><ul><li><strong>These are yours →Bunlar senin.</strong></li><li><strong>These are your books. →Bunlar senin kitapların.</strong></li><li><strong>Yours are here. →Seninkiler burada.</strong></li><li><strong>Yours is here. → Seninki burada.</strong></li><li><strong>Bu kedi onların →This cat is theirs</strong></li><li><strong>O bizim okulumuz. → It is our school.</strong></li><li><strong>Onunkini görebiliyor musun? →Can you see hers.</strong></li></ul><p>Bugünki yazı gerçekten baya kısaydı ama yukarıda bahsettim bu sıralar böyle olması lazım 6 sene üni okumak istemeyiz :)</p><p>Kalın sağlıcakla👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b3e4ec188a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>