Skip to main content

Posts

Showing posts from December, 2018

5 Common pitfalls while starting iOS app

In this article I listed 5 most common missteps while starting iOS application. Typically beginners might have taken these approaches.  1. Internet connectivity status checking over response error : It is essential to check network connectivity status offline or online before starting services.  To test reachability you might wrote in response callback :  Problem : Time consuming in case URL takes tool long to respond. More over you cannot rely on server to check connectivity. Simply because server may be down at the moment you sent request. Solution : Use Apple’s Reachability class. It can monitor network status of WiFi or Cellular data instantly. Notifies in case network status changes. Bonus - Also make sure app works in iPv6 network as well. 2. Textfield behind keyboard :  Credit : Stackoverflow.com We start developing app in Xcode and run in Simulator. By default keyboard preference of simulator is hidden and we kept using Mac keybo...

Protocol Oriented Programming (POP) in Swift

A protocol declares a programmatic interface that any class or structs or enums may choose to implement. It act as blueprints rather than parents. POP is a new approach for programming where you decorate your classes, structs or enums using protocols. By default swift does not support multiple inheritance, therefore problem pops out when you want to add multiple abilities to your class. Protocol OP lets you to add new abilities to a class or struct or enum via protocols which can support multiple implementations. For instance a ‘Car Engine’ protocol can implemented from ‘Petrol engine’’ and  ‘Electric engine’ protocol. Syntax : What about Object Oriented Programming (OOP) ? Creating abstract (methods without implementation) classes or base classes mainly done from inheritance. Every subclasses will have the ability of their super classes (unless ‘final’ method type ). A subclass can override that ability, add specific one. OOP works perfect till y...

Storyboard vs XIB vs Custom UI Code

Have you ever felt difficulty while choosing between Storyboard and XIB or even going for Custom code? Let’s make it easier from this short article. As we know, Storyboard introduced in iOS 5 and it consists of several ViewControllers, whereas XIB (previously NIB) files can consist of only one controller scene. Even custom codes can do all UI actions of such as positioning or animations..etc without help of any GUI tools.  Further, we may not need to stick with only one of above options. We can have one or combinations of three as per the requirement. Pros of Storyboard: As its name says, we can visualize entire scene in a single shot. On the Storyboard file, we can configure the flow between pages directly by using segue. Segues takes care most of UI configurations. Reduces boilerplate code needed to pop, push, present and dismiss view controllers. When storyboard makes sense? A set of views say for example: Authentications (Login/Registration page), Wi...

Implementing autocompletion OTP field in iOS

Long waiting is over. !!  iOS 12 brings Autofill for OTP text field which is close to Android provided a decade back. Previously in iOS we used to toggle between OTP text screen and message inbox.  Which was hard to remember and time consuming resulting a bad user experience. Personally, I have been asked from the client/customer couple of times to implement autocompletion for OTP field and took me a lot of time to convey that it is not possible in iOS. Why Autofill was not possible previously?  We all know that Apple gives at most care for user privacy. When we see iOS architecture, each individual app is like a separate island. There is no inter-app bridge between apps (exception for Keychain and URLSchemes APIs which gives very limited scope). Thus we cannot read message content from inbox. Where to start Autofilling? First of all, the target SMS need to have the OTP Code with prefix string "Code" or "Passcode"on its message content. Beware of OTP c...

Static Vs Dynamic libraries in iOS

A library is a collection of resources and the code itself, compiled for one or more architectures. Apple provides 2 types of library architectures that behaves differently upon building our app. Static libraries (*.a) :  When the app launches Static libraries loaded into address space for future use. They become part of the executable, and are statically linked to client apps. Thus, it (especially large executable libraries) makes apps slower to load and run, even launch time of the apps. Apple shown the architecture of static libraries as below : Dynamic libraries (*.dylib) :  With dynamic libraries, the app loads code into its address space when it’s actually needed, either at launch time or at runtime. The libraries are not part of the executable file. Thus decreases the memory footprint for your app. Clearly dynamic frameworks has got more advantages over static frameworks. Notably, it is available for iOS 8 and above. Apple shown the architecture...