Category Archives: Xcode

How will you create a static library in iOS?

By | September 27, 2015

What is a Static library? A static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable. This executable and the process of compiling it are both… Read More »

Create a date in your format in IOS

By | December 31, 2014

Below functions takes the current date and time and formats it to give a date-time string. You can customise it in the way you want. The string that the below function generates will be like this – 23-Dec-2014 4:23 PM [c] //Get the current date… +(NSDate *) getCurrentDate { NSDate *now = [NSDate date]; return now; } //Get… Read More »

Creating a Custom Alert or PopUp in iOS

By | November 15, 2014

First we will write a class that extends UIView to create a Custom PopUp Create a Cocoa file and name it CustomPopUp You should get two files CustomPopUp.h and CustomPopUp.m CustomPopUp.h [c] #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @protocol ClickDelegates; @interface CustomPopUp : UIView{ UIView *childPopUp; id<ClickDelegates> _click_delegate; UIViewController *_parent; } @property (nonatomic, retain) id<ClickDelegates> _click_delegate; @property (nonatomic, retain) UIViewController… Read More »

Handling Files in iOS

By | October 29, 2014

Hi All, In Todays article we will see how we can handle files in Objective C. The list of the methods used for accessing and manipulating files are listed below. Here you have to replace the FilePath1, FilePath2 and FilePath strings to our required full file paths to get the desired action. [c] NSFileManager *fileManager = [NSFileManager defaultManager];… Read More »

Delegates in iOS – A Simple Example

By | October 26, 2014

Hi All, Today I am going to talk about iOS Delagates. This example shows how to write a common delegate for a mail composer in iOS. First I am going to crate a seperate class for invoking the MailComposer Modal view controller. The class is named “Common”. So Create .m and .h files for Common. Common.h [c] #import… Read More »

How to add info button to right side or leftside of navigationbar in iPhone?

By | February 22, 2014

[c] UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [infoButton addTarget:self action:@selector(showInfoView:) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton]; [/c] Adding button action function. [c] – (IBAction)showInfoView:(id)sender { } [/c]

Random Integer array without repetition in Objective C Iphone

By | February 20, 2014

This sample code generates a random number and checks whether its already present in the array. If yes then it will not add else it will add, thus generating a random array without duplicates. [c] -(NSMutableArray *) generateRandomArray : (int) max{ NSMutableArray *randArray = [NSMutableArray new]; for (int k = 0; k < max; k++) { int r… Read More »

How to download an image from a URL in Objective C iPhone?

By | February 15, 2014

This method downloads the image from the specified URL and stores in the documents directory and then shown in an ImageView. Make sure you have an imageview linked with the outlet in the UserInterface. [c] -(void) downloadImageFromURL :(NSString *)imageUrl{ NSURL *url = [NSURL URLWithString:imageUrl]; NSData *urlData = [NSData dataWithContentsOfURL:url]; if ( urlData ) { NSLog(@"Downloading started…"); NSArray *paths… Read More »

How to create a radioGroup in Android inside a Scrollview?

By | February 14, 2014

Here is a sample code that creates a radiobutton group inside a scrollview. Please make sure you have a scrollview in your UI and its linked. // This function adds the radio buttons inside the scrollview. Here I am using some of my variables to generate the count of radio buttons. Please make sure to change it before… Read More »

How to split a string using a delimiter in iPhone and add it to a mutable array?

By | February 10, 2014

Here is a simple code that does this.. [c] -(NSMutableArray *) getAnswers :(NSString *) yourstring{ NSMutableArray *answers = [NSMutableArray new]; NSArray *parts = [[yourstring componentsSeparatedByString:@","]; for(NSString *str in parts){ [answers addObject:str]; } NSLog(@"RET answers %@", answers); return answers; } [/c] After splitting the string with “componentsSeparatedByString” the parts are added to a NSMutableArray using addObject.

How to call a function in background in Xcode(iPhone)?

By | January 5, 2013

“performSelectorInBackground” will call anyfunction to execute in background and you can also pass string parameters with this method or if you want to pass more params then pass the parameters as an object. [self performSelectorInBackground:@selector(myBackgroundMethod:) withObject:@”String Params”];