Skip to main content

Posts

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

Pocket guide to iOS app development enthusiasts

I would like to share all possible channels & resources that helps anyone can pitch in iOS development. I'm sure existing iOS ninjas who are already consuming those in one or other ways. Before listing my points - we all know it's most important to keep updated techs and trends. Many cases I have seen some of the below connections helped developers to get their new jobs or app contracts. 1. Apple's Official Developer guide. Apple Documentation  is the first go over for all references.  Swift.org for Swift Language starting point. WWDC Videos (& New app launched as well) 2. Social Media Groups - Fast & easy way to connect with iOS community. Facebook Group   Twitter Lists for iOS handles 3. Slack workspaces - A sweet hub of all iOS developers connected by channels. ios-developers.slack.com (Suggested) 4. Online Courses   - Gives opportunity to learn and be certified developers. Udemy AppBrewery  Alison ( and more ) 5. Exclusive i

♻️ Reusing Image with Template render mode in iOS

UIImage comes with property " renderingMode " from iOS 7 onwards. It can be set either 'alwaysTemplate' or 'alwaysOriginal'. This enum property helps us to re-use images that may thin your app size too. Let's get into to a real scenario ! I have added button as heart icon that gives like or dislike functionality for a picture. As you can see in the result below, heart image turns red when liked and stays gray when disliked. In such cases only one image asset can be used. Considering a UIButton object already created and added as a subview in the project, let's start with functionality. Again, I have only one image with name 'heart' in the asset folder (with gray fill). Using same image, I can create 2 instances of UIImage objects using rendering modes.     let notLikedImage = UIImage . init (named: "heart" )?. withRenderingMode (. alwaysOriginal )  let likedImage = UIImage . init (named: "heart" )?.

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 Cycle ov

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 UICollection

Static variable vs Class variable in Swift

How Static properties differs to usual properties ? Used to create type properties with either let or var. These are shared between all objects of a class.  During class loading time, a single memory location allocated for the property if we declared as static. Static property belongs to a class (or struct) Type rather than Instance of class (or struct). Hence it also called  Type Properties What if we declare "static var" ? Since it's a variable, we can change it in future even after initialised. When we change the value of the static variable property, that property is now changed in all future instances. What if we declare "static let" ? static let instance : Singleton = Singleton() Since it's constant, we cannot change once initialised. Its value will remain same even if we share among all the instance or object of a class or struct. Useful to adopt singleton pattern. How class variables differ static variables ? It dif

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)