Site icon codewithshabib

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

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

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!

To install it, simply add the following line to your Podfile:

pod 'SHTwoDimensionalArray'

and run

pod install

command!

To use this, try the following code snippet:

#import "SHTwoDimensionalArray.h"

SHTwoDimensionalArray *twoDArray = [SHTwoDimensionalArray arrayWithRows:2 andColumns:2];
[twoDArray setObject:@"Foo" inRow:0 column:0];
...

NSString *foo = [twoDArray objectInRow:0 column:0];

I hope you find it helpful and it’s under MIT license. Feel free to fork, modify and contribute!

Cheers!