Posts

Showing posts from October, 2012

Open htaccess Password Protected Web-Page in UIWebView

In some cases we want to access a password protected (htaccess) webpage from UIWebView iPhone. So for this we need add username and password between 'http://' and 'page url'.  e.g. @"http://username:password@192.165.1.11/mypage" NSString *url = @"http://username:password@192.165.1.11/mypage"; [webViewForhtaccessPageRendering loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: url]]]; here  webViewForhtaccessPageRendering is UIWebVIew.

UITableView - Add or Remove Rows Dynamically (Objective C & Swift Source codes)

Image
In some situations we need to add or remove rows dynamically from a UITableView. We can achieve it very easily, just got through the tutorial : 1. Create a new project. 2.  In AppDelegate implementation file create an object of UINavigationController (navController here). 3. Add object of UIViewController (viewController here) as rootviewcontroller of UINavigationController. 4. In ViewController.xib nib file take a UITableView. 5. Set delegate and datasource of UITableView to File's Owner. 6. Create an IBOutlet to UITableView (tableViewForScreen here) in ViewControler.h header file. 7. Declare an object of NSMutableArray (arrayForTableContent here) in ViewControler.h header file. 8. In ViewController.m file in viewDidLoad method set edit and add buttons as leftBarButtonItem and rightBarButtonItem respectively. 9. Initialize arrayForTableContent array and add objects to it.

Implementing iAd in iPhone/iPad/iPod Touch Application

Image
Implementing iAds in your iPhone/iPad Application is really very simple. 1. First add "iAd.framework" Framework from Targets -> Build Phases -> Link Binary With Libraries. 2. In ViewController.h #import  <iAd/ADBannerView.h> 3. Take ADBannerViewDelegate. 4. Now take a ADBannerView in ViewController.xib. 5. Set IBOutlet to ADBannerView (as iADBannerView here). 6. Set delegate of ADBannerView to File Owner(self). 7. In ViewController.m set iADBannerView as Hidden in viewDidLoad method. Which will hide the ADBannerView while loading controller screen. 8. Now add delegate methods of ADBannerView mentioned below: - ( void )bannerViewDidLoadAd:( ADBannerView *)banner; - ( void )bannerView:( ADBannerView *)banner didFailToReceiveAdWithError:( NSError *)error; 9. In bannerViewDidLoadAd method unhide the ADBannerView. As method name specifies this method is executed when ADBannerView loads. 10. If there is any is

Validate and Parse NSURL in Objective C

I need to check if Url is valid or not in my iPhone application so i found below snippet from   http://stackoverflow.com We can validate a url by simply using Foundation Framework as follows:           NSURL  *myURL = [ NSURL URLWithString : @"http://google.com" ];          if ( myURL  &&  myURL . scheme &&  myURL . host ) {              NSLog ( @"URL is validated" );         } else {             UIAlertView *alertMsg = [[ UIAlertView alloc ] initWithTitle : @"Error"                                        message : @"URL is invalid" delegate : nil                                        cancelButtonTitle : @"OK" otherButtonTitles : nil , nil ];             [alertMsg show ];             [alertMsg release ];         } Output:  URL is validated Above can be achieved using RegexKit also as follows:     NSString *regexExpression = @"(http|https)://((\\w)*|([0-

Database implementation using SQLite in iOS Applications

Image
SQLite:  I have worked on Core Data and SQLite both, but i personally feel that using SQLite is a good choice. Working on Database directly using SQLite is better than working on Core Data which actually works as a wrapper above SQLite. We can easily fire complex sql queries on Database using SQLite to store, update or fetch data; which is a pathetic job using Core Data.  Below is a simple demo app which will help you understand how to use SQLite to create database, store, update, fetch and delete records from database. For using SQLite database in iPhone, iPad App first you need to link libsqlite3.0.dylib to your build target.  To do this select 'Project' at top left navigation panel -> 'under Targets' select your build target -> then click on 'Build Phases' tab -> then in 'Link Binary With Libraries' click on '+' button and add libsqlite3.0.dylib.   There are number of C functions contained within the libsqlite3.