Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to create a custom Spinner

To create a custom spinner create a custom view with the following initialization method - (id)initWithFrame:(CGRect)frame superViewFrame:(CGRect)superViewFrame { self = [super initWithFrame:frame]; if (self) { // Initializ...

How to find current location of device (using CoreLocation framework)

There are two ways to find current location (lat,long) of device : Using CoreLocation framework OR using Mapkit framework. Here's how to get the location using CoreLocation framework : 1. Import CoreLocation/CoreLocation.h in h file of view...

Implementing AFNetworking

AFNetworking is currently the most popular 3rd party networking library for iOS and OSX. The latest version of AFNetworking (2.0) is built on top of NSURLSession which is the new preferred method of networking introduced in iOS 7 (in place of old...

Convert HTML string to Plane NSString

Hi Friends, Sometime in API responses we get html strings. To get pure string from html string this code will help you. NSString *htmlStr = @"html String"; NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDict...

How to detect screenshot taken by user in iPhone.

With the help of the notification "UIApplicationUserDidTakeScreenshotNotification" in our application we can detect the screenshot taken from iPhone. Use the following line of code to generate notification for same. [[NSNotificationCenter def...

Get iPhone contacts for any label in Objective C

Sometimes we do not get other label's contact number from the iPhone device. We only get "Mobile" labelled number or "iPhone" labelled number. Here is the code to get all type of labels contacts from an iPhone device. Inside the loop where we ...

URL encoding in ios

Hello all, I was facing problem with loading URL in UIWebVIew because of wrong encoding method. After that I tried this code. It helped me. - (NSString*)encodeURL:(NSString *)string { NSString *newString = NSMakeCollectable([(NSString *...

Customize commit editing style delete button in UITableViewCell

Hello All, Following lines of code will customize the delete button in UITableView editing style. This is an override method of UITableViewCell which is called when UITableView goes in editing mode. So to customize the delete button in UITable...

Some keyboard shortcuts in Xcode

Xcode provides many keyboard shortcuts that can save our lot of time. Here is a list of few shortcuts that you might want to try out: cmd+shift+o Open quickly ctrl+cmd+left arrow Go Back ctrl+cmd+right arrow Go Forward ctrl+cmd+up Jump to N...

How to pass the method name as argument string

Sometime we don't know name of the method at compile time. So pass the method name as argument and use the following lines of code. NSString *methodname=@"calltest"; SEL aSelector = NSSelectorFromString(methodname); NSInvocation *inv = [NS...

Using a dispatch semaphore with block

Blocks are a language-level feature, which allow us to create distinct segment of code. there are three way to recognize the semaphore. dispatch_semaphore_create => creates a semaphore with initial value dispatch_semaphore_signal => i...

How to stop scrolling of a scrolling UITableview programmatically

When we are having multiple tableviews with a common datasource we must make sure that only one table view is being reloaded at a time. We cannot load data on one table while other is scrolling as it would invoke datasource methods for the scroll...

How to invoke action on UISlider drag release

We might face situation where we need to do something after slider is released. This may be some code that takes a bit long to execute or makes a request to server or invokes a secondary thread or any such code executing continuously with slider ...

Open CSV and PDF file in your application

Add following line of code in your Plist file to open CSV and PDF file in your application. Please note that UTTypeIdentifier should be unique. <key>CFBundleDocumentTypes</key> <array> <dict> ...

Custom right bar button in UINavigationBar

Hello friends,This code is to make custom right bar button in UINavigation bar. it helped me to make custom right bar button in UINavigation bar, Hope this will help you too. UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom...

Detect device orientation and set UI according to orientation dynamically.

Hello Friends, these lines of code will help you to detect device orientation and set UI dynamically according to orientation. - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { NSLog(@"rotate");...

Push Notification in iOS

iOS Push Notification Tutorial:- Note:- Start following steps and dont do anything else. There are so many Gotchas while creating certificates but dont get confuse and follow these steps. Step 1:- Generating the Certificate Signing Req...

Load url in UIWebView.

Hello All, Following lines of code will help you to load url in UIWebView and make it fit to IPhone screen. In .h file IBOutlet UIWebView *webView; In .m file [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@...

Play videos sequentially using MPMoviePlayerController

Hello All, Sometime we want to play all videos of gallery sequentially. These lines of code will help you to play videos sequentially using MPMoviePlayerController.it worked for me. In .h file.. MPMoviePlayerController *moviePlayer; in...

To check that internet is available or not.

Hi Friends, sometimes we face problem in internet connectivity, With the following lines of code we can check whether we are connected to internet or not. - (BOOL)isNetworkAvailable { CFNetDiagnosticRef dReference; dReference = CFNe...

Draw a route between two annotation point on MKMapView

The following lines of code helped me to draw a route between two Annotation point in MKMapView Hope this will help you in your coding CSRouteAnnotation* routeAnnotation = (CSRouteAnnotation*)self.routeView.annotation; // only draw o...

How to encode and decode NSString

Following method will encode and decode NSString. Characters to leave unescaped (NULL = all escaped sequences are replaced). - (NSString *)URLEncodedString { CFStringRef url = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (...

How to get sorted NSArray of date for NSDictionary.

With the help of following code you can sort the given dictionary containing key as Date. @implementation NSMutableDictionary (SortingNSMutableDictionary) -(NSArray *)getAllSortedKeys{ NSMutableArray *array = [NSMutableArray arrayWithA...

How to rotate and zoom a view using UIGestureRecognizer

Rotating and zooming a view is a pretty simple task. This blog shows how rotate and zoom a view by implementing UIPinchGestureRecognizer and UIRotateGestureRecognizer. 1. Add pinch and rotate gesture recognizers to the target view. (Gesture ...

How to save a class on Parse

Hi guys , Here is a quick help of saving a class on parse cloud. Download Parse FrameWork. Import it. ParseSave.m NSMutableDictionary *dict=[[NSMutableDictionary alloc]initWithObjectsAndKeys:[data objectForKey:@"Id"],@"Id",[da...

How to drag(pan) a view on iPhone screen using UIPanGestureRecognizer

To drag a view we can either use the touch methods of UIViewController or we can use UIPanGestureRecognizer. UIPanGestureRecognizer is much easier and simple to implement. This blog explains how to use it. Add pan gesture to the view (or any...

How to filter an array

Sometimes we might need to filter a list of records. For instance : We have an array of employees and we want to get all employees who live in the city Dehradun. Here is the structure of Employee class : @interface Employee : NSObject @p...

How to check the Network availability for 3G and 4G connection

Following code will help in you to check the network availability for 3G and 4G connection const char *host&#95;name = "google.com"; BOOL _isDataSourceAvailable = NO; Boolean success; //Creates a reachability reference to ...

How to create dynamic UITableViewCell for Chat

Following code will help you to create dynamic UITableViewCell w.r.t to its content of message. -(void)setChatData:(ChatMessage *)messageObj memberDict:(NSDictionary *)memberDict isCurrentUser:(BOOL)isCurrentUser{ NSDictionary *user...

Import Phonebook contacts in Objective C

Get the complete list of phonebook contacts inside the app. We need to add two frameworks before proceed. Goo to Build Phase and Add these two:- #import < AddressBook/AddressBook.h> #import < AddressBookUI/AddressBookUI.h> ...

How to add Twitter account in your iPhone

The following code will help you to create your twitter account in your iPhone through coding. Also please note this code will only run in ios7 or later. -(void)createTwitterAccount{ ACAccountStore *store = [[ACAccountStore alloc]init]...

How to get complete address from latitude/logitude

Let's find out the latitude/longitude first to find out the address. 1) Add CoreLocation.framework under Targets -> Build Phases -> Link Binary With Libraries 2) Import in your view controller where you need to find out the address. 3)...

Finding address from latitude longitude in ios using CLGeocoder

CoreLocation framework of iOS provides method for finding address of a location using its latitude and longitude (also known as ReverseGeocoding). Following code snippet explains how to use it : CLLocation *location = targetlocation; ...

Best way to create a singleton class in Objective-C

There are different ways to create a singleton/shared instance of a class in Objective-C. Here I have explained two most preferred methods for it and both are thread safe. 1) Using "@synthesize" #define SINGLETON_FOR_CLASS(yourclassname...

UITableView or UIScrollView scrolls to top not working.

UIScrollView has a property called scrollsToTop which sets y of content offset of scrollview to zero on tapping the statusbar. But there might be situation when this functionality does not work. According to apple documentation "The scroll-to-...

How to calculate distance from CLLocationCoordinate2D

Using the following code we can calculate the distance between two CLLocationCoordinate2D. +(double)calculateDistance:(CLLocationCoordinate2D) f to: (CLLocationCoordinate2D) t { // CLLocation *locA = [[CLLocation alloc] initWithLati...

Get Pinterest Images into an iOS app

Simply to get User uploaded images from Pinterest we need to do following things first:- Install Pinterest native app on iOS device. Get logged in with any user credential. Now Hit the Pinterest API with passing . In json response you wil...

PageViewController

Hi Guys, Do you know how to implement PageViewController ? This is an IOS very good and efficient feature. Below I have implemented a example which will help you use the PageViewController. Lets assume you have create a Book for kids ...

XMPP integration using iOS sdks

If you want to add chat functionality in your iOS app . Then this blog can help you to do some basic chat functionality. Such as creating xmpp session , login on sever, creating room, getting list of login buddies and chatting. First step down...

Tabbar Customization

Snippet works all around to customize the tabbar icons & texts display color for selected and unselected state for iOS7 self.tabbarController.tabBar.tintColor = [UIColor greenColor]; Below code can be used to customize the text look. ...

How to save or delete caf file from NSDocumentDirectory

Follow these two methods to save or delete your .caf file from NSDocumentDirectory. -(NSString *)saveFileWithOldName:(NSString*)oldNameStr { NSArray *dirPaths; NSString *docsDirs; NSString *tempStr2; dirPaths = NSSearchPa...

Zoom an image using UIScrollView

The UIScrollView is used to view a content whose size is larger than the screen of the device. It can also be used to zoom in and zoom out an image, or to view an image that is significantly larger than the screen of the device. To make the scrol...

Transitioning with Views

To make the app look elegant and impressive, the programmers implement some animations or in other words transitions to switch between views. These transitions are provided by the Xcode libraries and are very easy to implement and use. The step b...

In app purchase sample code for iOS apps

Import StoreKit.Framework into your xcode project first. Apple allows three types of purchases within the app and Apple terms them as consumables, non-consumables and subscriptions. Consumables are products that are consumed immediately. ...

Resizing and Rotating UIImage

We often need to rotate or resize images in iPhone apps. Attached is a demo project that uses a handy category for doing the same. How to use : Add UIImage+Extension.h and UIImage+Extension.m to project. Import UIImage+Extension.h in re...

Some basic animation examples in iOS

Here are some basic animation examples like : Fade in/out, rotate, zoom etc. How to use : Add Animations.h and Animations.m files in your project. Import Animations.h class. Invoke required class method in this way : [Animations ...

How to register your app on facebook

Please follow these simple step to register your app on facebook Open Developer account from your Facebook. Select "Create App" you'll be directed to a page where number of options will be available at the top bar. One can reach there by j...

Fetch All Notifications

Snippet to fetch all local notifications of the app. One can customize any notification and cancel the same. UIApplication *app = [UIApplication sharedApplication]; NSArray *eventArray = [app scheduledLocalNotifications]; for (int ...

Slide-Out Navigation Panel

Slide-Out Navigation is quite popular nowadays. It enhances usability and gives a different look and feel to the app. Apps like Facebook, Path and many others use this feature. Attached with this blog is a nice library called SWRevealViewControll...

UICollectionViews

A relatively new feature of iOS is the UICollectionViews. The UICollectionView allows the programmer to arrange the data into cells, which in turn can be arranged in grids. The photos in the photo gallery of phone can be seen in thumbnails, a...
1 11 13
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: