Memory management in Swift: Strong Reference & Retain Cycle

Standard

Swift uses ARC (Automatic Reference Counting) similar to Objective-C to track and manage application memory. In most cases, we don’t need to bother about memory management by ourselves, the swift compiler will take care of it. But there are some cases where we need to deal with it  by ourselves. I am going to discuss some of the common cases from those.

Continue reading

UITextView similar to rounded UITextField with dynamic height

Standard

Ever wanted to use an UITextView that looks like a rounded UITextFiled? Also, wished it will grow it’s height as you type your text? Well, you are in luck! Here is the swift file you will need.

Continue reading

Delegation in iOS and Cocoa: Decorator Pattern

Standard

Using delegates in iOS and Cocoa is a very basic and fundamental part and we use them very frequently in our codes. As like in business, cocoa uses delegates as a formal way to pass work/data from one object to another. In business, you want to do make something but you need raw materials to do so. So you ask the supplier to give you raw materials and you sign a contract for that. Same goes in cocoa, a class that wants to perform a task that depends on the response of another class acts as the delegate to the later. The first class wants to be the contractor of the later one by signing a contract called protocols (as defined in cocoa).

Continue reading

SHViewPager: Android like view pager control for iOS Version 2.0 finally!

Standard

It has been almost or, more than 2 years I had created this controller called SHViewPager. And to my utmost surprise a lot of people actually got benefited from it. Some of them requested for the support for screen orientation and iPad. I was a bit busy (actually lazy! sorry guys, truly!)  to keep the request. Finally after a long wait, I was thinking, why am I not doing it?

Continue reading

SHTwoDimensionalArray : A simple and easy to use two dimensional array for iOS applications.

Standard

Ever felt the need to use a two dimensional array in you iOS project? Well, I have. So here is what I had done:

  • Created a NSObject subclass.
  • Taken two private NSMutableArray instances, one for row and one for column.
  • Created a nested for loop to traverse those arrays, and fill them with NSNull objects.
  • Created a method to insert value/object on the [row][column] index.

So this is fairly easy and straightforward. But wouldn’t it be nicer if you didn’t have to do all these steps and figure out how to write those monotonous codes all by yourself?

My good friend, I have good news for you! I have created a simple CocoaPod to minimize your task!

Continue reading

SHViewPager: Custom Controller for iOS

Standard

Hello everybody,

For a recent project of mine, I had created this custom controller. This is quite similar to the ViewPager control used in Android. I’ve named this controller SHViewPager, here is the gitHub link.
Continue reading

Objective-C: Space for Every Three Digits of A Number

Standard

Hi everyone and welcome again to my blog. Today I am going to discuss a quick fix with you guys. Recently I was working in one my projects and came to a point where I had to use a formatter, which will put spaces after every three digit of a decimal number. For example, if the number is 20000, it will make it look like 200 000. Simple and it is vastly used, isn’t it? Continue reading