<?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 Erdem Papakçı on Medium]]></title>
        <description><![CDATA[Stories by Erdem Papakçı on Medium]]></description>
        <link>https://medium.com/@erdempapakci?source=rss-c473d19eeaaf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JcPgAZkWWS_YNUCOeX2lWQ.jpeg</url>
            <title>Stories by Erdem Papakçı on Medium</title>
            <link>https://medium.com/@erdempapakci?source=rss-c473d19eeaaf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:45:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erdempapakci/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[Tight And Loose Coupling in Swift]]></title>
            <link>https://blog.stackademic.com/tight-and-loose-coupling-in-swift-f4db1e60fe5b?source=rss-c473d19eeaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4db1e60fe5b</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[swift-protocol]]></category>
            <category><![CDATA[loosely-coupled]]></category>
            <category><![CDATA[tight-coupling]]></category>
            <dc:creator><![CDATA[Erdem Papakçı]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 21:05:57 GMT</pubDate>
            <atom:updated>2023-09-04T00:33:51.390Z</atom:updated>
            <content:encoded><![CDATA[<h4>Program to an interface, not an implementation.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbmXMigq2R9QAWj6BOVj3A.jpeg" /><figcaption>Photo by<a href="https://unsplash.com/@josephyates_"> <strong>Joe Yates</strong></a><strong> </strong>on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p><em>I was searching for an image for Tight And Loose Coupling and I found this image that might be the most appropriate. 😅</em></p><p>In this article, delving into the concept of Tight and Loose Coupling within the Swift programming language. In this piece, we will elaborate on the definitions of coupling, <strong>tight coupling, </strong>and<strong> loose coupling</strong> in the context of Swift.</p><h3>Tight And Loose Coupling In Swift</h3><ul><li>The degree of interdependence distinguishes coupling as either <strong>Tight or Loose</strong>.</li><li>Tight coupling pertains to an entity closely relying on another entity within the same class.</li><li>Modifying one entity within a tightly coupled system necessitates adjustments to all instances where that entity is utilized in other classes.</li><li>Within Tight coupling, substituting the entity is complex due to its <strong>strong reliance</strong> on interactions with other classes.</li><li>On the other hand, Loose coupling surfaces when a class isn’t reliant on a particular object or class but rather on a <strong>protocol/interface</strong>.</li><li>In this scenario, dependencies aren’t tied to a specific implementation; instead, they adhere to a <strong>protocol/interface</strong>.</li></ul><h3>Tight Coupling</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f9cebf219e7776e9d460387ad41db8f/href">https://medium.com/media/2f9cebf219e7776e9d460387ad41db8f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dc34011159e80fecc7cf1aa8be000cc/href">https://medium.com/media/4dc34011159e80fecc7cf1aa8be000cc/href</a></iframe><p>Presently, we are illustrating a scenario where two classes are intimately interconnected, showcasing <strong>tight coupling</strong>. How did this tight coupling materialize? It originated from the direct instantiation and utilization of the API class within a Interactor. This reciprocal <strong>referencing</strong> establishes a link between them, thereby restricting the Interactor capacity to collaborate with the API class across diverse modules. Consequently, the Interactor possesses an in-depth understanding of the API class’s internal workings, a situation we aim to avoid.</p><h3>Solution</h3><p>To mitigate the effects of tight coupling, we can employ strategies such as <strong>dependency injection and abstraction</strong>. These techniques foster the development of code that is both <strong>modular and amenable to testing</strong>. The key lies in partitioning the components and establishing well-defined interfaces that facilitate their interaction.</p><p><strong>This problem can be solved in many ways, but we will consider two.</strong></p><h3>Loose Coupling</h3><h4>Protocol Based Approach</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c939054dfb03a0b1a4f4276d5a826312/href">https://medium.com/media/c939054dfb03a0b1a4f4276d5a826312/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/552db23dacdca509a7fcde586aa5dea9/href">https://medium.com/media/552db23dacdca509a7fcde586aa5dea9/href</a></iframe><p>With our current approach, <strong>flexibility</strong> is now at our disposal in terms of implementation. Testing our API class becomes feasible through the utilization of <strong>mocks, fakes, stubs</strong>, and other <strong>relevant techniques</strong>. Furthermore, expanding the capabilities of our API class is achievable without risking disruptions to our Interactor’s implementation. This subtle yet impactful adjustment has brought about a notable enhancement.</p><h4>Adapter Based Approach</h4><p>Let’s consider a scenario where we are managing two distinct databases or data repositories. The first involves a remote REST API service, while the other pertains to a local storage system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1764d479408b06faa26bd4897745473f/href">https://medium.com/media/1764d479408b06faa26bd4897745473f/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/803e99395d03d55a0d7382de347dd371/href">https://medium.com/media/803e99395d03d55a0d7382de347dd371/href</a></iframe><p>Consequently, our Interactor remains agnostic to the specific data store it’s linked with, completely oblivious to the intricacies of its implementation. This affords us a <strong>pliable and testable abstracted approach</strong>. As a result of these measures, our classes are now thoroughly decoupled, effectively handling dependencies in a well-organized manner.</p><h3>Conclusion</h3><p>The extent of interconnection among software components exerts a substantial influence on a system’s <strong>adaptability, expandability, and sustainability</strong>. While tight coupling may present certain merits like enhanced performance and precision, an architecture with looser coupling aligns more effectively with contemporary software development practices. This approach bestows advantages such as modularity, standardized interfaces, and detached communication. Nevertheless, the decision regarding the appropriate level of coupling hinges on the distinct necessities and stipulations of the given system.</p><p><strong>REFERENCES</strong></p><ul><li><a href="http://swift-lang.org/papers/pdfs/Swift-SWF07.pdf">http://swift-lang.org/papers/pdfs/Swift-SWF07.pdf</a></li><li><a href="https://www.donnywals.com/loose-coupling-and-the-law-of-demeter/">https://www.donnywals.com/loose-coupling-and-the-law-of-demeter/</a></li><li><a href="https://cleancommit.io/blog/whats-the-difference-between-tight-and-loose-coupling/#:~:text=A%3A%20Tight%20coupling%20refers%20to,and%20can%20operate%20more%20independently.">https://cleancommit.io/blog/whats-the-difference-between-tight-and-loose-coupling/#:~:text=A%3A%20Tight%20coupling%20refers%20to,and%20can%20operate%20more%20independently.</a></li></ul><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4db1e60fe5b" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/tight-and-loose-coupling-in-swift-f4db1e60fe5b">Tight And Loose Coupling in Swift</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Combine Network Layer to VIPER Architecture in Swift]]></title>
            <link>https://erdempapakci.medium.com/combine-network-layer-to-viper-architecture-in-swift-7dbb7ae91eec?source=rss-c473d19eeaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dbb7ae91eec</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[viper]]></category>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[combine-framework]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Erdem Papakçı]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 14:27:53 GMT</pubDate>
            <atom:updated>2023-07-21T11:59:01.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfZEMHqWV_4juPktDLk1pA.gif" /></figure><p>Introduced in 2019, Combine is still being compared to RxSwift even today. Actually, both of these enable you to work with functional reactive code, allowing the processing of values over time. You can think of instances of such values as network responses, user interface events, and various types of asynchronous data. But Combine performance looks one step ahead. Let’s examine these graphs before we get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hV-biOm2YA5JqW7zVLgySw.png" /><figcaption>Thank you for this great performance test: <a href="https://github.com/QuickBirdEng/CombineRxSwiftPerformance">https://github.com/QuickBirdEng/CombineRxSwiftPerformance</a></figcaption></figure><p>This significant difference in performance can be attributed, in part, to the way both frameworks are implemented. RxSwift primarily employs Swift as its main programming language and requires the opening of numerous sinks under the hood, which comes with a considerable performance cost. On the other hand, Combine is a<strong> closed-source project</strong> that may not necessarily be written entirely in Swift, but rather exposes a Swift interface.</p><p>Ok ok this is not the topic for now the title of the article was different I got carried away a little bit now we can go back to our topic. 😄</p><h4>EndPoints</h4><p>We are going to create basic endpoint classes and enums which we use in generic <strong>URLRequest</strong>. There are many ways to access the url, as we all know, we can use protocols for this and use new <strong>UrlQuery items</strong>, but since this is not our main purpose, I want to create a simple url to separate the some elements like <strong>paths, constants, method and URLRouters.</strong></p><pre>import Foundation<br><br>enum URLRouter {<br>    case podcast<br>    <br>    var path: String {<br>        switch self {<br>        case .podcast:<br>            return &quot;podcasts.json&quot;<br>        }<br>    }<br>}<br>public final class Constant {<br>    <br>    static let scheme = &quot;https://&quot;<br>    static let baseURL = &quot;rss.applemarketingtools.com/api/v2/&quot;<br>    <br>}<br>enum RequestMethod: String {<br>    case get = &quot;GET&quot;<br>    case post = &quot;POST&quot;<br>    case delete = &quot;DELETE&quot;<br>    case put = &quot;PUT&quot;<br>}</pre><h4>Url Requests</h4><p>We need 1 more parameter for <strong>count limit</strong> so we need to add it.</p><pre>    func buildRequest(<br>        router: URLRouter,<br>        parameters: [String: Any]? = nil,<br>        headers: [String: String]? = nil,<br>        count: Int,<br>        method: RequestMethod = .get<br>  <br>    )  -&gt; URLRequest? {<br>        <br>        let locale = Locale.current<br>        guard let countryCode = locale.language.region?.identifier.lowercased() else {<br>                return nil<br>            }<br><br>        let urlString = Constant.scheme + Constant.baseURL + countryCode + &quot;/podcasts/top/\(count)/&quot; + router.path<br>        guard let url = URL(string: urlString) else { return nil  }<br>        <br>         var request = URLRequest(url: url)<br>        <br>        request.httpMethod = method.rawValue<br>        request.setValue(&quot;application/json&quot;, forHTTPHeaderField: &quot;Content-Type&quot;)<br>        if let requestHeaders = headers {<br>            for (field, value) in requestHeaders {<br>                request.setValue(value, forHTTPHeaderField: field)<br>            }<br>        }<br>        <br>        return request<br>    }</pre><h4>AnyPublishers</h4><p>In the current process, we were able to create our url request, now we come to the part where we can use the actual <strong>combine</strong>.</p><pre>func get&lt;T&gt; (<br>        type: T.Type,<br>        router: URLRouter,<br>        parameters: [String: Any]? = nil,<br>        headers: [String: String]? = nil,<br>        count: Int,<br>        method: RequestMethod<br>    ) -&gt; AnyPublisher&lt;T, Error&gt; where T: Decodable {<br>        <br>        if let request = buildRequest(router: router, count: count) {<br>            return URLSession.shared.dataTaskPublisher(for: request)<br>                .tryMap(\.data)<br>                .decode(type: T.self, decoder: Decoders.Decoder)<br>                .eraseToAnyPublisher()<br>        }<br>       <br>        return Fail(error: NSError(domain: &quot;Server Error&quot;, code: 0))<br>            .eraseToAnyPublisher()<br>        <br>    }</pre><p>t looks very simple, doesn’t it, in fact it is as easy as it looks. Now let’s talk about what we have done.</p><ul><li><strong>AnyPublisher</strong>: AnyPublisher is a concrete implementation of Publisher that has no significant properties of its own, and passes through elements and completion values from its upstream publisher.</li><li><strong>DataTaskPublisher</strong>: The publisher publishes data when the task completes, or terminates if the task fails with an error.</li><li><strong>TryMap</strong>: By using the tryMap operator, you can transform the output of a dataTaskPublisher, which includes both response and data. This transformation involves initially checking whether the response is correct or not, and if not, an error is thrown; otherwise, the output is converted to data.</li><li><strong>Decode</strong>: A publisher that decodes a given type using a specified decoder and publishes the result.</li><li><strong>EraseToAnyPublisher</strong>: Function to erase the publisher’s type and make it an AnyPublisher.</li><li><strong>Fail</strong>: A publisher that immediately terminates with the specified error.</li></ul><h3>Fetching Data to VIPER</h3><p>So we already created our Generic APICalls now we only need to fetch this AnyPublisher to our view but do not forget we are using Viper Architecture this could take a bit time. 😄</p><h4>Contracts</h4><pre>import Foundation<br>import Combine<br><br>// View<br>protocol MainViewProtocol: AnyObject {<br>    func configureTableView()<br>    func reloadData()<br>}<br>// Presenter<br>protocol MainPresenterProtocol {<br>    func cellForRowAt(_ index: Int) -&gt; Podcast<br>    func numberOfRows() -&gt; Int<br>    func viewDidLoad()<br>    func load(count: Int)<br>  <br>}<br>// Interactor<br>protocol MainInteractorProtocol {<br>    <br>    func fetchData(count: Int) -&gt; AnyPublisher&lt;[Podcast],Error&gt;<br>}<br>// Router<br>// We will show just a tableview so do not need one</pre><h4>Model and Model Response — Entity</h4><pre>struct PodcastResponse: Decodable {<br>  <br>    enum RootCodingKeys: String, CodingKey {<br>       case feed<br>   }<br>   <br>    enum FeedCodingKeys: String, CodingKey {<br>       case results<br>   }<br>   let results: [Podcast]?<br>   <br>   public init(from decoder: Decoder) throws {<br>       let values = try decoder.container(keyedBy: RootCodingKeys.self)<br>       let feedContainer = try values.nestedContainer(keyedBy: FeedCodingKeys.self, forKey: .feed)<br>     <br>       results = try feedContainer.decodeIfPresent([Podcast].self, forKey: .results)<br>       <br>   }<br>   <br>   <br>}<br>struct Podcast: Decodable {<br>    <br>    let artistName: String<br>    let id: String<br>    let name: String<br>    let image: String<br>    let rating: String?<br>    <br>    enum CodingKeys: String, CodingKey {<br>        case artistName = &quot;artistName&quot;<br>        case id = &quot;id&quot;<br>        case name = &quot;name&quot;<br>        case image = &quot;artworkUrl100&quot;<br>        case rating = &quot;contentAdvisoryRating&quot;<br>    }<br>}</pre><h4>Interactor</h4><pre>final class MainInteractor: MainInteractorProtocol {<br>  <br>    let service: NetworkManagerProtocol<br>    <br>    init(service: NetworkManagerProtocol) {<br>        self.service = service<br>        <br>    }<br>   <br>    func fetchData(count: Int) -&gt; AnyPublisher&lt;[Podcast],Error&gt; {<br>return self.service.get(type: PodcastResponse.self, router: .podcast, parameters: nil, headers: nil, count: count, method: .get)<br>            .tryMap({ $0.results ?? []})<br>            .eraseToAnyPublisher()<br>            <br>    }<br>    <br>}</pre><p>We are fetching the Podcast data and mapping the data as Podcast. I like to init in this class because we can call from some Containers and we can mock the Network.</p><h4>Presenter</h4><pre>final class MainPresenter: MainPresenterProtocol {<br>    <br>    private var cancellables = Set&lt;AnyCancellable&gt;()<br>   <br>    private unowned let view: MainViewProtocol<br>    var router: MainRouterProtocol<br>    var interactor: MainInteractorProtocol<br>    init(view: MainViewProtocol, router: MainRouterProtocol, interactor: MainInteractorProtocol) {<br>        self.view = view<br>        self.router = router<br>        self.interactor = interactor<br>    }<br>    <br>    var podcasts: [Podcast] = []<br>    <br>    func cellForRowAt(_ index: Int) -&gt; Podcast {<br>        return podcasts[index]<br>    }<br>  func numberOfRows() -&gt; Int {<br>       <br>        return podcasts.count<br>    }<br>  <br>    func viewDidLoad() {<br>        view.configureTableView()<br>    <br>    }<br>    func load(count: Int) {<br>        <br>       interactor.fetchData(count: count)<br>            <br>            .receive(on: DispatchQueue.main)<br>            .sink { completion in<br>                switch completion {<br>                case .failure(let error):<br>                    print(error)<br>                case .finished: break<br>                }<br>            } receiveValue: { [weak self] users in<br>                self?.podcasts = users<br>                self?.view.reloadData()<br>            }<br>            .store(in: &amp;cancellables)<br>    }<br> <br>}</pre><p>Let’s take a closer look at the load function, we fetching data from interactor and calling receive sink and store what does it all mean.</p><ul><li><strong>Receive: </strong>Specifies the scheduler on which to receive elements from the publisher.</li><li><strong>Sink</strong>: Attaches a subscriber with closure-based behavior. So we can handle failure or finished cases.</li><li><strong>ReceiveValue:</strong> Attaches a subscriber with closure-based behavior to a publisher that never fails.</li><li><strong>Store</strong>: Stores this type-erasing cancellable instance in the specified collection. We could have more “cancellables” in one object so we can keep in a Set.</li></ul><h4>View</h4><p>It is a simple ViewController which only show tableview.</p><pre>final class MainViewController: BaseViewController, MainViewProtocol {<br>   <br>    var presenter: MainPresenterProtocol!<br>    <br>    private let tableView: UITableView = {<br>       let tableView = UITableView()<br>        tableView.register(UITableViewCell.self, forCellReuseIdentifier: &quot;cell&quot;)<br>        <br>        return tableView<br>    }()<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        <br>        presenter.viewDidLoad()<br>        presenter.load(count: 10)<br>    }<br>    override func viewDidLayoutSubviews() {<br>        super.viewDidLayoutSubviews()<br>        view.addSubview(tableView)<br>    }<br>    func configureTableView() {<br>        tableView.delegate = self<br>        tableView.dataSource = self<br>        tableView.frame = view.frame<br>    }<br>    func reloadData() {<br>        DispatchQueue.main.async { [weak self] in<br>            guard let self = self else {return}<br>            self.tableView.reloadData()<br>        }<br>    }<br>    <br>    <br>    <br>}<br>extension MainViewController: UITableViewDelegate, UITableViewDataSource {<br>    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {<br>        <br>        return presenter.numberOfRows()<br>    }<br>    <br>    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {<br>        let cell = tableView.dequeueReusableCell(withIdentifier: &quot;cell&quot;)!<br>        cell.textLabel?.text = presenter.cellForRowAt(indexPath.row).artistName<br>       <br>        return cell<br>        <br>    }<br>    <br>    <br>}</pre><p>And we finished the project 👏 🎉</p><p>If there is something I missed or something you think is wrong, you can contact me, I am always happy to learn something new.</p><ul><li>If you want to see the full project you can click on the <a href="https://github.com/erdempapakci/Combine-Viper-Networking">link</a>.</li></ul><p><strong>REFERENCES</strong></p><ul><li><a href="https://developer.apple.com/documentation/combine">https://developer.apple.com/documentation/combine</a></li><li><a href="https://www.kodeco.com/books/combine-asynchronous-programming-with-swift/v2.0/chapters/2-publishers-subscribers">https://www.swiftbysundell.com/basics/combine/</a></li><li><a href="https://github.com/QuickBirdEng/CombineRxSwiftPerformance">https://github.com/QuickBirdEng/CombineRxSwiftPerformance</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dbb7ae91eec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SwiftData Nedir? (WWDC2023)]]></title>
            <link>https://erdempapakci.medium.com/swiftdata-nedir-wwdc2023-1d7ecf063bec?source=rss-c473d19eeaaf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d7ecf063bec</guid>
            <category><![CDATA[wwdc-2023]]></category>
            <category><![CDATA[swiftdata]]></category>
            <category><![CDATA[xcode15]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Erdem Papakçı]]></dc:creator>
            <pubDate>Tue, 04 Jul 2023 13:49:42 GMT</pubDate>
            <atom:updated>2023-07-04T13:49:42.109Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ml-TtQtHRihhIUVVFNyzQQ.gif" /></figure><blockquote><em>Yıllar boyunca Core Data, Apple’ın platformlarında kalıcı depolama için tercih ettiği seçenek olmuştur. Ancak geliştiriciler Core Data ile ilgili sorunlarla karşılaşmış ve bu zorlukların üstesinden gelmek için alternatif frameworkler aramışlardır. WWDC23&#39;te Apple, SwiftUI ile sorunsuz bir şekilde entegre olmak üzere özel olarak tasarlanmış SwiftData adlı yeni persistance frameworkü tanıttı. Şimdi sizlere basit bir uygulama ile SwiftDatayı uygulamamıza nasıl entegre edebileceğimizi göstermek istiyorum.</em></blockquote><p><strong>@ Model</strong></p><p>Data öncesinde yaratacağımız modelimiz yaklaşık olarak bu şekilde olması gerekiyordu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lY5OTR1Gzc8Ng-nJ8gLZjg.png" /></figure><p>SwiftData ile artık bir modeldeki her değişkene <strong>@Published</strong> ile açıklama eklemenize veya <strong>ObservableObject</strong>sınıfından miras almanıza gerek yok. Bunun yerine SwiftData, nesneyi farklı çalıştırmalarda kalıcılığa hazır hale getirmek için gerekli adımları otomatikleştiren <strong>@Model</strong> makrosundan yararlanarak süreci basitleştiriyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ks9hVKJf876d3voqJOqx4g.png" /></figure><p><strong>Model Container</strong></p><p>Verilerin tutulduğu ve uygulamanın schema ve model storagesinin yapılandırmasını yöneten nesnedir ve <strong>Model Container</strong>’ı WindowGroupta düzenleyebiliriz. Aynı zamanda içerisine birden fazla data modeli de yazabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*zqjBkPqcS9XHUWjaHyeNzg.png" /></figure><p><strong>Model Context</strong></p><p>Modelleri üzerinde<strong> CRUD</strong> (Create, Read, Update, Delete ) işlemleri yapmamızı sağlar ve CoreData frameworkündeki <strong>ViewContext</strong> gibi çalışır. Şimdi verilerimizi kaydettik ve diğer işlemleri tamamladık sırada bu verileri fetchleme işlemimiz kalıyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*dEAHLsYOpPDmongp_0l0cw.png" /></figure><p><strong>Kaydetme, Silme işlemleri</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mbog5Ha91fKqhCrLyNDshw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gsvIqGfMMf7g38I6pAdclw.png" /></figure><p><strong>@ Query</strong></p><p>Veriyi view e taşımamızı sağlar ve verinin her değişiminde UI’ı günceller. Data source olarak <strong>ModelContext</strong> i kullanır.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*uvYR7w_RkERbNSdsjK6rVA.png" /></figure><p>Aynı zamanda içerisinde <strong>filter, order, sort</strong> gibi işlemleri gerçekleştirebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dr-UQ4jNOVPsBa69Bu7X5Q.png" /></figure><p>⚠️ <em>SwiftDatayı yalnızca XCode 15 Beta sürümünde kullanabileceğimizi unutmayalım </em>⚠️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Xgv-mNEUt4yPaA40g-plA.gif" /></figure><p><strong>Ve uygulamamızın sonuna geldik günün sonunda SwiftDatayı kullanarak bir app geliştirmiş olduk.</strong></p><ul><li><a href="https://github.com/erdempapakci/WWDC2023_SwiftData_Example">Projenin tamamlanmış halini görmek için.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d7ecf063bec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>