Category: iOS

iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company’s mobile devices, including the iPhone and iPod Touch; the term also included the versions running on iPads until the name iPadOS was introduced with version 13 in 2019. It is the world’s second-most widely installed mobile operating system, after Android. It is the basis for three other operating systems made by Apple: iPadOS, tvOS, and watchOS. It is proprietary software, although some parts of it are open source under the Apple Public Source License and other licenses.

  • My thoughts on SwiftUI

    My thoughts on SwiftUI

    I recently completed one medium size SwiftUI project and, it was a wonderful experience with MVVM architecture. I took some time to grab everything, but my struggles been paid off.

    I no longer want to do a new project on the storyboard. You should not do it either. No fear just start you will finish it soon.

    Storyboard was some improvements than single xib file, at least you did not have to open many tabs for xib which always slowed down Xcode. But it was always like this on Apple platform since Xcode 3.2, developing app means you have to handle xib file.

    I always liked Android’s XML way than a xib file on a Xcode.

    I never liked the Auto Layout either, but it always worked on all devices. But I hated it when I had to break a few constraints to add a few more to make space for a new TextField or Image. It has never been easy.

    The most useful thing about SwiftUI that how easy it is to create a view and reuse it anywhere if you can make it in that way. The @Binding and @State are really helpful.

    And the ViewModel updates a model which your view observes always. So my ViewModel has a property @Published whenever it changes its all observers will get the update by calling the property @ObservedObject or @StateObject.

    The SwiftUI is very new but it is the best thing for app developers on Apple platforms. I even converting few more apps in SwiftUI in the coming months.

    Download a demo login app I’m working on from github.

    Spread the love
  • Radio Buttons group in SwiftUI

    Radio Buttons group in SwiftUI

    Radio Buttons group in SwiftUI

    Radio Buttons group in SwiftUI, is not hard to implement classic radio button group in your SwiftUI. Though this project is in very early stage, I will work on this in coming days to enhance its features.

    Installation: Add RadioButtonGroup.swift in your SwiftUI project.

    Usages: Create model class, must conform to RadioModelable protocol

     class RadioModel: RadioModelable {
        var id: Int
        var isChecked: Bool
        var label: String
        
        required init(id: Int, isChecked: Bool, label: String) {
            self.id = id
            self.isChecked = isChecked
            self.label = label
        }
    }

    Create data provider class, must conform to RadioDataProviding protocol

    class DataProvider<T>: RadioDataProviding where T: RadioModelable {
        @Published var items: [RItem] = []
        
        init() {
            
            self.items = getItems()
        }
        
        func getItems() -> [T] {
            return [T(id: 1, isChecked: true, label: "Radio 1"),
                    T(id: 2, isChecked: false, label: "Radio 2"),
                    T(id: 3, isChecked: false, label: "Radio 3")]
        }
        
        func toggle(id: Int) {
            for var item in self.items {
                if item.id == id {
                    item.isChecked = true
                } else {
                    item.isChecked = false
                }
            }
            
            self.objectWillChange.send()
        }
    }

    Finally add in your view

    struct ContentView: View {
        var body: some View {
            SRadioButtonViewGroup(dataProvider: DataProvider<RadioModel>(), selectedItem: getSelectedItemLabel)
        }
        
        func getSelectedItemLabel<T>(item: T) {
            print("selected item : \((item as! RadioModel).label)")
        }
    }

    Preview

    Download source code

    Spread the love
  • No Builds Available on TestFlight

    You may find this issue when adding a new tester on the TestFlight page, question is how this user going to get the invitation.

    Suppose you are adding a tester for version 2.4 and the error message looks like this.

    All you have to do is go to the previous version 2.3 and add the new tester on that version. After the user accepts the invitation you won’t see the error for that user for any new versions.

    Spread the love