Posts

WebService Handler on AFNetworking

Step1 pod 'AFNetworking','~> 2.5' Step 2 #import "AFNetworking.h" @interface WebServiceHandler : NSObject @property ( nonatomic , strong ) AFHTTPRequestOperationManager *reqOperationManager; -( void )call:( eMethodType )methodType withUrl:( NSString *)serviceUrl withParameter:( NSDictionary *)parameters onCompletion:( void (^)( eResponseType responseType, id response))completionBlock; Step 3 #import "WebServiceHandler.h" #import "Reachability.h" #define TIME_OUT 60.0f @implementation WebServiceHandler -( instancetype )init {     self = [ super init ];     if ( self ) {                  _reqOperationManager = [[ AFHTTPRequestOperationManager alloc ] initWithBaseURL :[ NSURL URLWithString : kBASE_URL ]];              }     return self ; } /**  *  This method creates NSMutableURLRequest and AFHTTPRequestOperation object, start operation. When ser

inline HTML in UILable

//  UILabel + Html.h #import @interface UILabel ( Html ) -( void ) setHTMLText:( NSString *)htmlText; @end //  UILabel+appLabel.m #import "UILabel+appLabel.h" @implementation UILabel ( Html ) -( void ) setHTMLText:( NSString *)htmlText{     dispatch_async ( dispatch_get_main_queue (), ^{         NSError *err = nil ;         self . attributedText = [[ NSAttributedString alloc ] initWithData : [htmlText dataUsingEncoding : NSUTF8StringEncoding ]                                                                options : @{ NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType }                                                     documentAttributes : nil                                                                  error : &err];                  if (err)             NSLog ( @"Unable to parse label text: %@" , err);     }); } @end

NSObject+LocalStorage

//  NSObject+LocalStorage.h //  Created by Avneesh.minocha on 19/05/15. #import typedef NS_ENUM (NSUInteger, kModalType) {     kTypeLogin = 1, }; @interface NSObject (LocalStorage) /**  *  This method is use to save any modal in local storage  *  *  @param type name of modal in a form of enum.  */ - ( void )saveLocally:( kModalType )type; /**  *  This method is use to fetch any modal from local storage  *  *  @param type name of modal in a form of enum.  *  *  @return modal object  */ - ( instancetype )fetchLocally:( kModalType )type; /**  *  This method is use to delete any modal from local storage  *  *  @param type name of modal in a form of enum.  */ -( void )removeAllinLocal:( kModalType )type; @end //NSObject+FFLocalStorage.m //  Created by Avneesh.minocha on 19/05/15. #import "NSObject+LocalStorage.h" @implementation NSObject (LocalStorage) -( NSString *)keybykModalType:( k

Intercept Ajax calls in UIWebview - iOS

Step 1 /* Steps to follow 1. Copy the following code. 2. Paste in text file. 3. Save as ajax_handler.js 4. keep this file in your resource folder var s_ajaxListener = new Object(); s_ajaxListener.tempOpen = XMLHttpRequest.prototype.open; s_ajaxListener.tempSend = XMLHttpRequest.prototype.send; s_ajaxListener.callback = function () {     window.location='mpAjaxHandler://' + this .url; }; XMLHttpRequest.prototype.open = function (a,b) {     if (!a) var a='';     if (!b) var b='';     s_ajaxListener.tempOpen.apply( this , arguments);     s_ajaxListener.method = a;     s_ajaxListener.url = b;     if (a.toLowerCase() == 'get') {         s_ajaxListener.data = b.split('?');         s_ajaxListener.data = s_ajaxListener.data[1];     } } XMLHttpRequest.prototype.send = function (a,b) {     if (!a) var a='';     if (!b) var b='';     s_ajaxListener.tempSend.apply