Wednesday, 10 December 2014

Links

Search bar tutorial:
http://www.appcoda.com/search-bar-tutorial-ios7/


ASIHTTP Request:
http://allseeing-i.com/ASIHTTPRequest/How-to-use

Barcode Reader:
http://zbar.sourceforge.net/iphone/sdkdoc/tutorial.html

Setting Remainder: 
http://www.raywenderlich.com/64513/cookbook-making-calendar-reminder

Screen Resolution and splash screen:
https://forums.adobe.com/thread/1575669
http://www.iosres.com/
http://ivomynttinen.com/blog/the-ios-7-design-cheat-sheet/


TableView With Radio Button:
http://stackoverflow.com/questions/25642756/radio-button-inside-the-uitableview-not-working


TableView With Check Box:
http://stackoverflow.com/questions/3666629/how-to-add-checkboxes-to-uitableviewcell

Graph in Table View:

http://stackoverflow.com/questions/21017412/drawing-a-bar-graph-using-uitableviewcell-cells-variably-partially-filled-wit

UIView Animation:



Page Control:


Auto Complete:


Navigation Controller Text:



Custom Fonts:



Custom Cell In Table View Programmatically:



Block Sample:












Wednesday, 10 September 2014

JSON Parser-GET,POST Method

1.kemal.co/index.php/2012/02/fetching-data-with-getpost-methods-by-using-nsurlconnection/
2.http://stackoverflow.com/questions/4456966/how-to-send-json-data-in-the-http-request-using-nsurlrequest

Wednesday, 14 May 2014

Run timer in background thread

ViewController.H


@property (nonatomic) UIBackgroundTaskIdentifier backgroundTask;

ViewController.M

self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        NSLog(@"Background handler called. Not running background taxsks anymore.");
        [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
        self.backgroundTask = UIBackgroundTaskInvalid;
    }];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countup)userInfo:nil repeats:YES];
        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
        [[NSRunLoop currentRunLoop] run];
    });

-(void)countup { 
  //Here i done another action run in main thread
 dispatch_async(dispatch_get_main_queue(), ^{  
               ViewController *Vc=[self.storyboard instantiateViewControllerWithIdentifier:@"view"];
                [self.navigationController pushViewController:Vc animated:YES];
            });
}

Assign placeholder image in tableview Cell(Load image asynchrous)

if u Load original image from server,it will take time at that time we show a another image still that original image loaded:


NSURL *imageURL = [NSURL URLWithString:Details.imageUrl];
    cell.imageView.image=[UIImage imageNamed:@"flower.png"];
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSData *data = [NSData dataWithContentsOfURL:imageURL];
        
        if (data) {
            UIImage *offersImage = [UIImage imageWithData:data];
            if (offersImage) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    UITableViewCell *updateCell = [tableView cellForRowAtIndexPath:indexPath];
                    
                    if (updateCell) {
                        updateCell.imageView.image = offersImage;
                    }
                });
            }
        }

    });

Tuesday, 13 May 2014

show html file in webview

 NSString * localHtmlFilePath =[[NSBundle mainBundle]pathForResource:@"frnd " ofType:@"html"];
    NSString *html = [NSString stringWithContentsOfFile:localHtmlFilePath encoding:NSUTF8StringEncoding error:nil];

   [webview loadHTMLString:html baseURL:nil];

Navigation concepts


//Change the Title Image in  navigation bar:
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower.png"]];

//Checking version 6 or 7 for changing background color of navigation bar
 NSString *version = [[UIDevice currentDevice] systemVersion];
    if ([version floatValue] < 7) { 
        self.navigationController.navigationBar.barTintColor=[UIColor blackColor];
    } else {
        self.navigationController.navigationBar.tintColor=[UIColor blackColor];
    }

//Hide the back button

    [self.navigationItem setHidesBackButton:YES animated:YES];

//Create custom Back button:
UIButton* customBackButton = [UIButton buttonWithType:101];
    [customBackButton setTitle:@"Back" forState:UIControlStateNormal];
    [customBackButton addTarget:self action:@selector(done:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem    *myBackButton = [[UIBarButtonItem alloc] initWithCustomView:customBackButton];
    self.navigationItem.backBarButtonItem=myBackButton;

//Create Right bar button: (more than one button)
UIBarButtonItem* allFriends = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"frnds.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(allfrnd:)];
    
    UIBarButtonItem* setting = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"options.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setting)];

    self.navigationItem.rightBarButtonItems=@[setting,allFriends];



//Programmatically pushing a root view controller it embedded with navigation controller
ViewController *user=[self.storyboard instantiateViewControllerWithIdentifier:@"user"];
                UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:user];
                [self.navigationController presentViewController:navigationController animated:YES completion:nil];

Get current Location using googlemaps

[GMSServices provideAPIKey:@"AIzaSyAemkuHXhydxhR286ECVVtspCVTstmgBQM"]; // This key is used for Google Maps.

    // Codes to start tracking the location of the user.
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.distanceFilter = kCLDistanceFilterNone;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    return YES;
}

- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations {
    CLLocation *clLocation = [locations lastObject];
    NSLog(@"Current latitude %f",clLocation.coordinate.latitude);
    NSLog(@"Current longitude %f",clLocation.coordinate.longitude);

}


Refer:https://developers.google.com/maps/documentation/ios/start

Convert TimeStamp into date

    double time=[timeStamp doubleValue]/1000;
    NSTimeInterval _interval=time;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"dd/MM/yyyy hh:mm"];

    NSString *dateString=[formatter stringFromDate:date];

Sunday, 2 February 2014

some Useful Links

Facebook and twitter post

ADD Framework:Social,Accounts

ViewController.h

#import <Social/Social.h>
#import <Accounts/Accounts.h>
@interface ViewController : UIViewController
-(IBAction)twitterPost:(id)sender;

-(IBAction)facebookPost:(id)sender;

Viewcontroller.M

-(IBAction)facebookPost:(id)sender{
    
    SLComposeViewController *controller = [SLComposeViewController
                                           composeViewControllerForServiceType:SLServiceTypeFacebook];
    SLComposeViewControllerCompletionHandler myBlock =
    ^(SLComposeViewControllerResult result){
        if (result == SLComposeViewControllerResultCancelled)
        {
            NSLog(@"Cancelled");
        }
        else
        {
            NSLog(@"Done");
        }
        [controller dismissViewControllerAnimated:YES completion:nil];
    };
    controller.completionHandler =myBlock;
    //Adding the Text to the facebook post value from iOS
    [controller setInitialText:@"My test post"];
    //Adding the URL to the facebook post value from iOS
    [controller addURL:[NSURL URLWithString:@"http://www.test.com"]];
    //Adding the Text to the facebook post value from iOS
    [self presentViewController:controller animated:YES completion:nil];
}

-(IBAction)twitterPost:(id)sender{
    SLComposeViewController *tweetSheet = [SLComposeViewController
                                           composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:@"My test tweet"];
    [self presentModalViewController:tweetSheet animated:YES];
}

Sending Mail

Add framework :MessageUI

Viewcontroller.h
#import <MessageUI/MessageUI.h>
@interface ViewController : UIViewController<MFMailComposeViewControllerDelegate>{
     MFMailComposeViewController *mailComposer;
}

-(IBAction)sendMail:(id)sender;

ViewController.M
-(IBAction)sendMail:(id)sender{
    mailComposer = [[MFMailComposeViewController alloc]init];
    mailComposer.mailComposeDelegate = self;
    [mailComposer setSubject:@"Test mail"];
    [mailComposer setMessageBody:@"Testing messagefor the test mail" isHTML:NO];
     [self presentModalViewController:mailComposer animated:YES];
     }
     
-(void)mailComposeController:(MFMailComposeViewController *)controller
             didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
                 if (result) {
                     NSLog(@"Result : %d",result);
                 }
                 if (error) {
                     NSLog(@"Error : %@",error);
                 }
                 [self dismissModalViewControllerAnimated:YES];
                 
             }

Adjust size of the image programmatically-Taj

 UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"taj.jpg"]];
    imageView.frame = CGRectMake(50, 100, 217  ,217);

    self.view.center=imageView.center;

Move button through coding

viewcontroller.h
 IBOutlet UIButton *button;

viewController.m

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch=[[event allTouches]anyObject];
    button.center=[touch locationInView:self.view];

}

Counting Timer

ViewController.h

@interface ViewController : UIViewController{
    NSTimer *timer;
    int MainInt;
     IBOutlet UIButton *drag;
}

@property (weak, nonatomic) IBOutlet UILabel *l1;
- (IBAction)click:(id)sender;
-(void)countup;
- (IBAction)stopTimer:(id)sender;

- (IBAction)reset:(id)sender;

viewcontroller.M

-(void)countup {
    MainInt += 1;
    l1.text = [NSString stringWithFormat:@"%i", MainInt];
    
    
}

- (IBAction)click:(id)sender {
    //MainInt = 0;
    if (timer==nil)
    {
    
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                             target:self selector:@selector(countup)userInfo:nil repeats:YES];
        
    }
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch=[[event allTouches]anyObject];
    drag.center=[touch locationInView:self.view];
    
}
- (IBAction)stopTimer:(id)sender
{
    if (timer != nil)
    {
        [timer invalidate];
        timer = nil;
    }
}

- (IBAction)reset:(id)sender {
    MainInt=0;
    
    
}

Audio and Video

1. ADD AVFoundation and Mediaplayer  Framworks
2.Import header file <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>

3.ViewController.h
@interface ViewController : UIViewController{
AVAudioPlayer *audioPlayer;
    MPMoviePlayerViewController *moviePlayer;

}
-(IBAction)playAudio:(id)sender;

-(IBAction)playVideo:(id)sender;

4.ViewController.M
-(IBAction)playAudio:(id)sender{
    NSString *path = [[NSBundle mainBundle]
                      pathForResource:@"song" ofType:@"mp3"];
    audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:
                   [NSURL fileURLWithPath:path] error:NULL];
    [audioPlayer play];
}
-(IBAction)playVideo:(id)sender{
    NSString *path = [[NSBundle mainBundle]pathForResource:
                      @"video" ofType:@"mov"];
    moviePlayer = [[MPMoviePlayerViewController
                    alloc]initWithContentURL:[NSURL fileURLWithPath:path]];

    [self presentModalViewController:moviePlayer animated:YES];
}

Thursday, 30 January 2014

scaling an image

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"taj.jpg"]];
    imageView.frame = CGRectMake(100, 100, 417  ,517);
    imageView.center = imageView.superview.center;

    [self.view addSubview:imageView];

Thursday, 23 January 2014

Table Without CustomCell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier=@"test";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        
    }
    cell.textLabel.text=[arr objectAtindex:indexpath.row];
    return cell;
    

}

Wednesday, 22 January 2014

Multiple CheckBox

-(IBAction)ChkUnChk:(id)sender //To connect all buttons
{
    
    UIButton *btn=(UIButton *)sender;
    NSString *Str=[NSString stringWithFormat:@"%d",btn.tag];
    BOOL flag=   [selectedBtnarr containsObject:Str];
    
    if (flag==YES)
    {
        [btn setBackgroundImage:[UIImage imageNamed:@"A.jpg"]    forState:UIControlStateNormal];
        [selectedBtnarr removeObject:Str];
    }
    else
    {
        [selectedBtnarr addObject:Str];
        [btn setBackgroundImage:[UIImage imageNamed:@"che1.png"] forState:UIControlStateNormal];
    }

}

Single Radio Button and Checkbox

-(void)viewDidAppear:(BOOL)animated{
    
    //Checkboxes
    
    checkbutton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    [checkbutton setBackgroundImage:[UIImage imageNamed:@"check.jpeg"] forState:UIControlStateNormal];
    [checkbutton setBackgroundImage:[UIImage imageNamed:@"che1.png"] forState:UIControlStateSelected];
    [checkbutton addTarget:self action:@selector(checkboxSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:checkbutton];

    //radio buttons
    radiobutton = [[UIButton alloc] initWithFrame:CGRectMake(0, 80, 20, 20)];
    [radiobutton setTag:0];
    [radiobutton setBackgroundImage:[UIImage imageNamed:@"radio.jpeg"] forState:UIControlStateNormal];
    [radiobutton setBackgroundImage:[UIImage imageNamed:@"sel.jpeg"] forState:UIControlStateSelected];
    [radiobutton addTarget:self action:@selector(radiobuttonSelected:) forControlEvents:UIControlEventTouchUpInside];
    
    radiobutton2 = [[UIButton alloc] initWithFrame:CGRectMake(80, 80, 20, 20)];
    [radiobutton2 setTag:1];
    [radiobutton2 setBackgroundImage:[UIImage imageNamed:@"radio.jpeg"] forState:UIControlStateNormal];
    [radiobutton2 setBackgroundImage:[UIImage imageNamed:@"sel.jpeg"] forState:UIControlStateSelected];
    [radiobutton2 addTarget:self action:@selector(radiobuttonSelected:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:radiobutton];
    [self.view addSubview:radiobutton2];
}

-(void)checkboxSelected:(id)sender{
    
    
    if([checkbutton isSelected]==YES)
    {
        [checkbutton setSelected:NO];
    }
    else{
        [checkbutton setSelected:YES];
    }
    
}
-(void)radiobuttonSelected:(id)sender{
    switch ([sender tag]) {
        case 0:
            if([radiobutton isSelected]==YES)
            {
                [radiobutton setSelected:NO];
                [radiobutton2 setSelected:YES];
            }
            else{
                [radiobutton setSelected:YES];
                [radiobutton2 setSelected:NO];
            }
            
            break;
        case 1:
            if([radiobutton2 isSelected]==YES)
            {
                [radiobutton2 setSelected:NO];
                [radiobutton setSelected:YES];
            }
            else{
                [radiobutton2 setSelected:YES];
                [radiobutton setSelected:NO];
            }
            
            break;
        default:
            break;
    }
    

}

Gesture Program

//Add framwork
iAd.framework

//ViewController.H
#import <iAd/iAd.h>
@interface ViewController : UIViewController<ADBannerViewDelegate>
@property (strong, nonatomic) IBOutlet UILabel *statusLabel;

@property (strong, nonatomic) IBOutlet ADBannerView *bannerView;

//ViewController.M
@implementation ViewController
@synthesize statusLabel,bannerView;

- (void)viewDidLoad
{
    [super viewDidLoad];
    bannerView = [[ADBannerView alloc]initWithFrame:
                  CGRectMake(0, 0, 320, 50)];
    // Optional to set background color to clear color
    [bannerView setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview: bannerView];
    
    
    UITapGestureRecognizer *doubleTap =
    [[UITapGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(tapDetected:)];
    doubleTap.numberOfTapsRequired = 2;
    [self.view addGestureRecognizer:doubleTap];
    //[doubleTap release];
    
    UIPinchGestureRecognizer *pinchRecognizer =
    [[UIPinchGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(pinchDetected:)];
    [self.view addGestureRecognizer:pinchRecognizer];
    //[pinchRecognizer release];
    
    UIRotationGestureRecognizer *rotationRecognizer =
    [[UIRotationGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(rotationDetected:)];
    [self.view addGestureRecognizer:rotationRecognizer];
    //[rotationRecognizer release];
    
    UISwipeGestureRecognizer *swipeRecognizer =
    [[UISwipeGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(swipeDetected:)];
    swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
    [self.view addGestureRecognizer:swipeRecognizer];
    //[swipeRecognizer release];
    
    UILongPressGestureRecognizer *longPressRecognizer =
    [[UILongPressGestureRecognizer alloc]
     initWithTarget:self
     action:@selector(longPressDetected:)];
    longPressRecognizer.minimumPressDuration = 3;
    longPressRecognizer.numberOfTouchesRequired = 1;
    [self.view addGestureRecognizer:longPressRecognizer];
    //[longPressRecognizer release];
    [super viewDidLoad];
}
// Do any additional setup after loading the view, typically from a nib.


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)longPressDetected:(UIGestureRecognizer *)sender {
    statusLabel.text = @"Long Press";
}

- (IBAction)swipeDetected:(UIGestureRecognizer *)sender {
    statusLabel.text = @"Right Swipe";
}

- (IBAction)tapDetected:(UIGestureRecognizer *)sender {
    statusLabel.text = @"Double Tap";
}

- (IBAction)pinchDetected:(UIGestureRecognizer *)sender {
    
    CGFloat scale =
    [(UIPinchGestureRecognizer *)sender scale];
    CGFloat velocity =
    [(UIPinchGestureRecognizer *)sender velocity];
    
    NSString *resultString = [[NSString alloc] initWithFormat:
                              @"Pinch - scale = %f, velocity = %f",
                              scale, velocity];
    statusLabel.text = resultString;
    }

- (IBAction)rotationDetected:(UIGestureRecognizer *)sender {
    CGFloat radians =
    [(UIRotationGestureRecognizer *)sender rotation];
    CGFloat velocity =
    [(UIRotationGestureRecognizer *)sender velocity];
    
    NSString *resultString = [[NSString alloc] initWithFormat:
                              @"Rotation - Radians = %f, velocity = %f",
                              radians, velocity];
    statusLabel.text = resultString;
    }

-(void)bannerView:(ADBannerView *)banner
didFailToReceiveAdWithError:(NSError *)error{
    NSLog(@"Error loading");
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    NSLog(@"Ad loaded");
}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
    NSLog(@"Ad will load");
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
    NSLog(@"Ad did finish");
    
}

Create Grid

-(void) layoutGrid {
         
         
         UIColor *c3;
         UIScrollView *sc=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 480, 320)];
         sc.userInteractionEnabled=YES;
         sc.backgroundColor=[UIColor purpleColor];
         sc.delegate=self;
         sc.scrollEnabled=YES;
         sc.contentSize=CGSizeMake(1000,800);
         [self.view addSubview:sc];
                  NSInteger grid[20][20];
         NSInteger k = 0;
         for (int row = 0; row <10; row++) {
             
             for (int column = 0; column <20; column++) {
                 if(column%2==0){
                     c3=[UIColor blackColor];
                 }
                 else{
                     c3=[UIColor whiteColor];
                 }
                 k++;
                 grid[row][column] = k;
                 UIView *lbl = [[UIView alloc] initWithFrame:CGRectMake(column*50, row * 50, 40, 40)];
                 [lbl setBackgroundColor:c3];
                
                 [sc addSubview:lbl];
         
                                  sc.userInteractionEnabled=YES;
             }
         }
         

     }

Reverse A string

NSString *s=text.text;

    int i=[s length];
    NSMutableString *arr=[[NSMutableString alloc]initWithCapacity:i];
    for ( int j=i-1; j>=0; j--) {
        [arr appendString:[NSString stringWithFormat:@"%c",[s characterAtIndex:j]]];
    }

    NSLog(@"%@",arr);

Preference

Header File:

<UIImagePickerControllerDelegate, UINavigationControllerDelegate>


//ViewController.M
- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    // Get the stored data before the view loads
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *firstName = [defaults objectForKey:@"firstName"];
    NSData *imageData = [defaults dataForKey:@"image"];
    UIImage *contactImage = [UIImage imageWithData:imageData];
    // Update the UI elements with the saved data
    txt_name.text = firstName;
    
    img_photo.image = contactImage;
}

- (void)viewDidUnload
{
    [self setTxt_name:nil];
    [self setImg_photo:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)Save:(id)sender 
{
    // Create strings and integer to store the text info
    NSString *firstName = [txt_name text];
    
    
    // Create instances of NSData
    UIImage *contactImage = img_photo.image;
    NSData *imageData = UIImageJPEGRepresentation(contactImage, 100);
    // Store the data
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:firstName forKey:@"firstName"];
    [defaults setObject:imageData forKey:@"image"];
    [defaults synchronize];
    NSLog(@"Data saved");
}

- (IBAction)Choose:(id)sender 
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:picker animated:YES];
}

#pragma mark - Image Picker Delegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    img_photo.image = image;
    [picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissModalViewControllerAnimated:YES];

}

PList

//PList path
    NSString *path = [[NSBundle mainBundle] pathForResource:@"PropertyList" ofType:@"plist"];

    stringArray = [[NSMutableArray alloc] initWithContentsOfFile:path];

System Date And Time

//ViewController.H

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    NSDate *date;
    
}
//ViewController.M
date=[NSDate date];
    NSDateFormatter *dateformat=[[NSDateFormatter alloc]init];
    [dateformat setDateFormat:@"HH:mm:ss \n dd:MM:YYYY"];
    NSString *string1=[dateformat stringFromDate:date];

    labletime.text=string1;

SQL Without FMDB

- (void)viewDidLoad
{
    
    NSString *docsDir;
    NSArray *dirPaths;
    //dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
    docsDir = [dirPaths objectAtIndex:0];//
    databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"contacts.db"]];
     NSFileManager *filemgr = [NSFileManager defaultManager];
    if ([filemgr fileExistsAtPath: databasePath])
    {
        const char *dbpath = [databasePath UTF8String];
    
        if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
        {
            char *errMsg;
            const char *sql_stmt = "CREATE TABLE IF NOT EXISTS CONTACTS(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, ADDRESS TEXT, PHONE TEXT)";
            if (sqlite3_exec(contactDB, sql_stmt, NULL, NULL, &errMsg)!= SQLITE_OK)
            {
                status.text = @"Failed to Create Table";
            }
            sqlite3_close(contactDB);
        }
        else
        {
            status.text = @"Failed to Open/Create Database";
        }
    }
    
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
//SAVED
- (void) saveData
{
    
    sqlite3_stmt *statement;
    const char *dbpath = [databasePath UTF8String];
    NSLog(@"%s",dbpath);
    if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK )
    {
        NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO CONTACTS (name, address, phone) VALUES (\"%@\", \"%@\", \"%@\")", name.text, address.text, phone.text];
        const char *insert_stmt = [insertSQL UTF8String];
        
        sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);
        if (sqlite3_step(statement) == SQLITE_DONE)
        {
            status.text = @"Contact Added";
            name.text = @"";
            address.text = @"";
            phone.text = @"";
        }
        else
        {
            status.text = @"Failed to Add Contact";
        }
        sqlite3_finalize(statement);
        sqlite3_close(contactDB);
    }
    
    

}

SQL-FMDB

-(void) createDatabase
{
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [dirPaths objectAtIndex:0];
    NSString *databasePath = [docDir stringByAppendingPathComponent:@"samcontact.sqlite"];
    
    FMDatabase *database = [FMDatabase databaseWithPath:databasePath];
    
    [database open];
    
    [database executeUpdate:@"create table phone(Name varchar, Address varchar, phoneno numeric)"];
    NSLog(@"Database created");
    NSLog(@"Path is : %@ ",databasePath);
    [database close];
}
//INSERT
- (IBAction)btn_insert:(id)sender 
{
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [dirPaths objectAtIndex:0];
    NSString *databasePath = [docDir stringByAppendingPathComponent:@"samcontact.sqlite"];
    
    FMDatabase *database = [FMDatabase databaseWithPath:databasePath];
    
    [database open];
    
    [database executeUpdate:@"insert into phone (Name, Address, phoneno) values(?,?,?)",txt_Name.text,txt_Address.text,txt_Contact.text];
    
    
    UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"Sample SQLite" message:@"Inserted Successfully" delegate:Nil cancelButtonTitle:@"OK"otherButtonTitles: nil];
    [alert show];
    
    [database close];
    
    txt_Name.text = @"";
    txt_Address.text = @"";
    txt_Contact.text = @"";
}
//SELECT
- (IBAction)btn_Select:(id)sender 
{
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [dirPaths objectAtIndex:0];
    NSString *databasePath = [docDir stringByAppendingPathComponent:@"samcontact.sqlite"];
    NSString *str;
    NSString *num;
    NSString *name;
    FMDatabase *database = [FMDatabase databaseWithPath:databasePath];
    
    [database open];
    FMResultSet *results = [database executeQuery:@"select * from phone where Name = ?",txt_Name.text];
    
     NSLog(@"select * from phone where Name = \"%@\"",txt_Name.text);
    
    while ([results next])
    {
        name = [results stringForColumn:@"Name"];
        str = [results stringForColumn:@"Address"];
        num = [results stringForColumn:@"phoneno"];
        
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"Sample SQLite" message:@"Find Successfully" delegate:Nil cancelButtonTitle:@"OK"otherButtonTitles: nil];
        [alert show];
        
    }
    txt_Name.text = name;
    txt_Address.text = str;
    txt_Contact.text = num;
    
    
    
    [database close];


}