Skip to main content

Posts

Showing posts with the label Beginner

Quick look on abbreviations in SE (Software Engineering)

 Here's a quick reference list with some common abbreviations that I have came across frequently in my Engineering journey :  1. PR – Pull Request A request submitted by a developer to merge their code changes from one branch to another, typically for review and collaboration before integration. 2. MR – Merge Request Similar to a Pull Request, a Merge Request is used in GitLab to request code merging. It includes review, discussion, and approval before finalizing changes. 3. CR – Change Request A formal proposal to modify a system or product, often triggered by stakeholder feedback, bug reports, or evolving requirements. 4. LADR – Lightweight Architectural Decision Record A brief document that captures an important architectural decision made during a project. 5. BRD – Business Requirement Document Outlines the high-level business needs, objectives, and expectations of a project. It's used as a reference for aligning technical development with business goals. 6. LLD – Low...

Sorting Algorithms – Quick Reference for Interviews

Sorting is a fundamental operation in computer science and Understanding the basic sorting algorithms is essential for both interviews and real-world programming tasks. I am sharing the notes that I have taken in my learning curve. 1. Selection Sort Selection Sort repeatedly finds the minimum element from the unsorted part and puts it at the beginning. Steps: Loop through the array. For each index, find the smallest element in the rest of the array. Swap it with the current index. Time Complexity: O(n²) Example: [29, 10, 14, 37, 13] → [10, 29, 14, 37, 13] → [10, 13, 14, 37, 29] → [10, 13, 14, 37, 29] → [10, 13, 14, 29, 37] 2. Insertion Sort Insertion Sort builds the sorted array one element at a time by inserting each element into its correct position. Steps: Start from index 1. Compare current element with the left-side elements. Shift elements to the right and insert at the correct position. Time Complexity: O(n²) Example: [8, 4, 1, 3] → [4, 8, 1, 3] → [1, 4, 8, 3] → [1, 3, 4, 8] 3. ...

Printing Staircase Pattern : Swift coding challenge

In this post, we can try interesting pattern printing challenge in Swift. The problem statement goes like this " Print a staircase of given size 'n'. Make sure that its base and height are both equal to n, and the image is drawn only using `#` symbols and spaces. The last line is not preceded by any spaces." Expected Output : # ## ### #### ##### ###### Working solution: func makePatternOf ( _ size : Int ) { var str = "" // 1 for index in ( 0 ..< size ) { let stop = size -index-1; // 2 for _ in 0 ..< stop { str. append ( " " ) ; } // 3 for _ in 0 .. . index { str. append ( "#" ) ; } print ( str ) str = "" } } makePatternOf ( 6 ) Loop to visit every row of stair case. Loop for appe...

Codility Challenge : Tennis tournament

In this post, we have Swift 5.0 solution for - Given the number of players P and the number of reserved courts C, returns the maximum number of games that can be played in parallel. For Example, Given P = 5 players and C = 3 available courts, the function should return 2. Working solution :      public func solution ( _ P: Int , _ C: Int ) -> Int {     // 1     if P < 2 || C < 1 {       return 0     }          // 2     return P >= (C * 2 ) ? C : (P / 2 ) % C   }    solution ( 5 , 3 ) // returns 2 When insufficient Players or Courts, games can not be played. If total players exceeds courts capacity, all courts occupied & games will be played. Otherwise return total number of games played from Players strength. Full detail of exercise challenge : https://app.codility.com/programmers/trainings/3/tennis_tournament/ Happy coding !

Reclaim the Xcode occupied space

  Open  Terminal  from Mac and run commands one by one.  > sudo rm -rf /.DocumentRevisions-V100/ > rm -rf ~/Library/Developer/Xcode/DerivedData > rm -rf ~/Library/Developer/Xcode/Archives  > rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport > rm -rf ~/Library/Caches/com.apple.dt.Xcode > xcrun simctl delete unavailable What happens ?? 1. Removes the snapshot of opened documents.  2. Removes all derived data that generated from Xcode projects.  3. Removes the archived builds from all apps. 4 iOS device support files dropped. 5. Clear caches from Xcode. 6. Deletes unused & outdated iOS simulator versions. 

Reference Type vs Value Type

How do we get to know reference type ?  In Swift , a class or closure or function can be Reference Type. In Objc, everything inherited from NSObject represents Reference Type. How do we get to know value type ?  In Swift, we have Structures, Enums and Tuples, along with Int, Double, String, Array, Dictionary, Set as well. In Objc, Number literals like NSInteger, C structures like CGPoint. When to use Reference type ? Comparing two objects those shares the same memory address (aka === ) When you want to create a shared and mutable state When to use Value Type ? Comparing instance data with == makes sense.  You want copies to have independent state.  The data will be used in code across multiple threads. How about memory Allocation ?  Heap memory for reference types.  Stack for Value types. Linked to similar questions : Struct vs Class String vs NSString (Source-Internet)

Quick 4 steps to get start with Test Flight for iOS

We can quickly distribute app to a specific set of beta testers over-the-air immediately with Test flight. In the below short note, I listed 4 simple steps to begin with Test Flight.  Step 1:    ’Test Flight’ app needs to be installed in the iPhone device & login to Apple account mail (Previously shared with Developer) in the same. App Store download link Step 2:  Whenever a developer publishes a new build (via iTunes connect panel), All testers will receive an invitation mail from Test Flight. Step 3:   After invitation accepted, Open the test flight app, install test build.  Example for step 2 & 3 ( Image Source : Appcoda) Step 4: Now we can start testing the app. In case any future app build updates, testers will receive notifications. That's all. Hope these steps will help new testers & promises a great quality app in the app store. 

Top App Store rejections and common reasons

Apple scans on each and every app submitted to App store. Our responsibility is to make sure app followed all  App Store review guidelines  and will get approved before dead line. But sometimes the guidelines are interpreted differently by different reviewers and frequently change over time.  Interestingly, I exposed to some common and "repetitive" rejections. Those I listed below and you are welcome to consider it as your checklist. 1. If the app contains any kind of bugs and crashes will surely rejected. Make sure app involved in testing and cleared test cases. Also involved various iPhone models & iOS version in the process. 2. Lacking of meta data is also leads to rejection. The key point is Apple expects behaviour of app should match with app description.  3. If the app submitted with demo features will be considered as incomplete. So make sure your app  doesn't include keys like 'Beta', 'Demo' or 'Test'. 4. Even missing demo a...

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...

Language Server Protocol (LSP) for Swift

You might already heard “ Apple announced LSP support for Swift ”. This is overwhelming decision by Apple because it’s a great step towards openness from it’s ‘monopoly game’. You can check complete official announcement here by Argyrios Kyrtzidis . What exactly LSP and How it works ? This Post from NSHipster by Matt explains how it works and what are the benefits out of the LSP support. In short, LSP will enable Swift development other than Xcode with below seamless integrated features - Autocompletion Jump to Definition Syntax highlighting Tooltips Automatic formatting and many for editor features. Any editor (say Visual Studio) to understand Swift, it requires Swift package to be integrated. Thus, SourceKit-LSP (Still under development) comes into play. This open source project got contribution from large group of developers and releasing very soon. Later we can easily integrate Swift into any editing tool with the help of any package manager (NodeJS prefer...

Stored Properties vs Computed Properties

We will start with simple a property which can be defined as below : var firstValue : Int let length : Int = 22 We can see it's not defined inside any closure, (A Closure "{ }" is meant for Classes, Structures or Enumerations) Stored Properties are those properties kept inside Classes and Structures. (not enums) . So, it will be always instance of classes or structures. Here is 2 more examples  : struct FixedLengthRange { var firstValue : Int let length : Int } class FixedLengthRange { var firstValue : Int let length : Int } Computed properties are those properties which do not store values, instead it gives getter and optional setter methods to access those property values. struct Circle {   var rad = 0   let pi = 3.14   var area : Float    {      get {        return rad * rad * pi          }   ...

iOS Beginner Level [Part 2/4]: Familiar Objective-C Classes

[1] NSUserDefaults NSUserDefaults object used to read information and caches information in user’s default data base.  Stores the data in Plist. The synchronised method of this class automatically invoked at a period of intervals to sync  the memory cache the data base. ex: `[defaults synchronize];` Always returns the immutable values. Non-persistent data storage. [2] NSBundle  This object locates your app in the file system from where you can access resources and use them in your programs. [3] UIResponder:  Subclass of NSObject defines the interface for objects ( likely abstract class) objects responds to this class and it handles those events. It is the super class of UIApplication, UIWindow , UIView (including all of its subclasses). Handles all type of touch events, motion events. [4] NSCoder  NSCoder is an abstractClass which represents a stream of data. They are used in Archiving and Unarchiving objects. NSCoder objects are...

IOS Beginner level [Part 1/4]: Basic concepts and terminology

Started developing iOS  apps? Great ! Before that make sure you have familiar with basic concepts covered in this post. Most probably you started using, but  totally unaware of it.  All these topics are the checklist for your next interview or your presentation and also you are welcome  even if use it as cheatsheet.  Again I want to stress that it covers only the topic definition or few lines of description. You can find good tutorial sites for rest of in depth explanation. [1] App A large ecosystem of interconnected objects that communicate with each other to solve specific problem such as displaying user interface, responding events, inputs and storing information. [2] App ID App id is a 2 part string used to identify one or more apps from a single development team. Combination of Team Id and Bundle ID separated by a period character(.) There are 2 types of App Id’s , an Explicit app id used for single app and wildcard app ids (with domain na...

Popular posts from this blog

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...

Animating label text update - choosing a better way

Recently I published a countdown app .  At one point of development - I have to show a timer on a UILabel which ticks on each seconds. As usual I started  setting text to a label object - self .timerLabel.text = someString Easy piece of cake right !?   But wait ... it won't take much user attention when timer ticks on every seconds. So I decided to make use of a simple animation while label gets text update. I found there are dozens of ways to animate a label. In this short article, I listed 3 best way you can animate text on a label. ( Spoiler Alert 👀- I decided to go with 3rd option)  1. Fade In - Fade out animation : CATransition class has got transition type `fade`. With timing function of CATransition - I was able to see the below result. let animation: CATransition = CATransition () animation.timingFunction = CAMediaTimingFunction (name: CAMediaTimingFunctionName .easeInEaseOut) animation.type = CATransitionType .fade animation.subtype = C...

Cached Async Image in SwiftUI

 SwiftUI’s AsyncImage is handy, but every time your view appears, it refetches the image—leading to flicker, delays, and unnecessary network use. What if you could fetch once, then reuse instantly? That's exactly what the Cached Async Image  delivers: a memory-powered caching layer that keeps SwiftUI image loading smooth, snappy, and resilient. First a simple in-memory cache without disk persistence. This will be thread-safe and auto-purges under memory pressure. A Singleton wrapping NSCache for URL → UIImage caching as follows : final class ImageCache {   static let shared = ImageCache()   private init() {}   private let cache = NSCache<NSURL, UIImage>()   func image(for url: URL) -> UIImage? {     cache.object(forKey: url as NSURL)   }   func insertImage(_ image: UIImage?, for url: URL) {     guard let image else { return }     cache.setObject(image, forKey: url as NSURL)   }   func clearAll() { ...

Prevent Navigationbar or Tabbar overlapping Subview - solved for Card view

Recently, I started with a Card view added as a subview of UIView in a view-controller. When a view controller created along subviews, it tends to use entire screen bounds and also slips behind Tab bar or Navigation bar. In my current situation, it's second case. Casually new iOS developers will write a patch by additional value for coordinate y and subtracting bar height from its size. A lot of them posted in SO threads too : How to prevent UINavigationBar from covering top of view? View got hidden below UINavigationBar iOS 7 Navigation Bar covers some part of view at Top So, how I got solved ? self.edgesForExtendedLayout = [] This  will avoid all subviews in a view controller get behind any bars. Read full apple  documentation on here. Full Source code below :  //Simple view controller where its view layed-out as a card. class WidgetCardViewController : UIViewController { var containerView = UIView () //MARK:- View Controller Life Cyc...

UICollectionViewCell shows with wrong size on First time - Solved

We commonly use Collection view where its cell size calculated run time. The flow layout delegate is responsible to return individual cell sizes. BUT in most of the cases, delegate method `collectionView: layout sizeForItem:` expects cell size too early. Before generating actual cell size. extension YourViewController : UICollectionViewDelegateFlowLayout { func collectionView ( _ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize (width: externalWidth, height: externalHeight) } } For instance, if a cell size depends on external view and its frame is not yet ready - results with wrong (or outdated) cell size. Typically happens for the first time view controller laid out all views. You can find similar queries in StackOverflow community : Collection view sizeForItemNotWorking UICollectionViewCell content wrong size on first load How to refresh UICollec...