Monday, 23 February 2015

All Gesture

All Gesture



TAP Gesture :


1 ) First Set Image In Imageview in
     The Storyboard :



2) Write Following Code in ViewController.h :


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    UIImageView *imgobj;
    UITapGestureRecognizer *tapgestureobj;
}

@property(strong,nonatomic)IBOutlet UIImageView *imgobj;
@property(strong,nonatomic)IBOutlet UITapGestureRecognizer *tapgestureobj;



@end


3) Write Following Code in ViewController.m :


#import "ViewController.h"

@interface ViewController ()


@end

@implementation ViewController
@synthesize imgobj,tapgestureobj;


- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tapgestureobj = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapselect:)];
    [tapgestureobj setNumberOfTouchesRequired:1];
    [tapgestureobj setNumberOfTapsRequired:1];
    
    
    [self.imgobj addGestureRecognizer:self.tapgestureobj];
    
    
    imgobj.userInteractionEnabled = YES;
    
}

-(void)tapselect : (UITapGestureRecognizer *)recognizer
{
    
    
    if (recognizer.view.contentMode == UIViewContentModeScaleToFill)
    {
        recognizer.view.contentMode = UIViewContentModeCenter;
    }
    else
    {
        recognizer.view.contentMode = UIViewContentModeScaleToFill;
    }
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end




Swipe Gesture :

1 ) First Set Three View With Different Colour in      The Storyboard :




2) Write Following Code in ViewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

{
    UIView *view1;
    UIView *view2;
    UIView *view3;
}

@property(strong,nonatomic)IBOutlet UIView *view1;
@property(strong,nonatomic)IBOutlet UIView *view2;
@property(strong,nonatomic)IBOutlet UIView *view3;


@property(strong,nonatomic)UISwipeGestureRecognizer *swipeleftobj;
@property(strong,nonatomic)UISwipeGestureRecognizer *swiperightobj;
@property(strong,nonatomic)UISwipeGestureRecognizer *swipetopobj;

@end


3) Write Following Code in ViewController.m :

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize view1,view2,view3,swipeleftobj,swiperightobj,swipetopobj;

- (void)viewDidLoad
{
    [super viewDidLoad];
    swipeleftobj = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeleftselect:)];
    swipeleftobj.direction = UISwipeGestureRecognizerDirectionLeft;
    
    
    swiperightobj = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiperightselect:)];
    swiperightobj.direction = UISwipeGestureRecognizerDirectionRight;
    
    swipetopobj = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipetopselect:)];
    swipetopobj.direction = UISwipeGestureRecognizerDirectionUp;
    
    
    
    [self.view1 addGestureRecognizer:swipeleftobj];
    [self.view2 addGestureRecognizer:swiperightobj];
    [self.view3 addGestureRecognizer:swipetopobj];
    
}

-(void)swipeleftselect : (UISwipeGestureRecognizer *)recognizer
{
    [UIView animateWithDuration:0.5 animations:^{
        self.view1.frame = CGRectOffset(self.view1.frame, -320.0, 0.0);
            }];
}

-(void)swiperightselect : (UISwipeGestureRecognizer *)recognizer
{
    [UIView animateWithDuration:0.5 animations:^{
                self.view2.frame = CGRectOffset(self.view2.frame, 320.0, 0.0);
            }];
}

-(void)swipetopselect : (UISwipeGestureRecognizer *)recognizer
{
    [UIView animateWithDuration:0.5 animations:^{
        self.view3.frame = CGRectMake(self.view3.frame.origin.x, -568, self.view3.frame.size.width, self.view3.frame.size.height);
    }];
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


Long Press Gesture :

1 ) First Set One View in The Storyboard :




2) Write Following Code in ViewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UIGestureRecognizerDelegate>
{
    UIView *view1;
    UILongPressGestureRecognizer *longobj;
}

@property(strong,nonatomic)IBOutlet UIView *view1;
@property(strong,nonatomic)UILongPressGestureRecognizer *longobj;


@end

3) Write Following Code in ViewController.m :

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize longobj,view1;

- (void)viewDidLoad
{
    [super viewDidLoad];
longobj = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longselect:)];
    longobj.minimumPressDuration = 0.3;
    longobj.delegate = self ;
    
    
    [self.view1 addGestureRecognizer:longobj];
    
    
}

-(void)longselect : (UILongPressGestureRecognizer *)recognizer
{
    if ([recognizer isEqual:self.longobj])
    {
        if (recognizer.state == UIGestureRecognizerStateBegan)
        {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Gestures" message:@"Long Gesture Detected" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
        }
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



Pinch Gesture :

1 ) First Set Image In Imageview in
     The Storyboard :



2) Write Following Code in ViewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UIGestureRecognizerDelegate>
{
    UIImageView *imgobj;
    UIPinchGestureRecognizer *pinchobj;
}

@property(strong,nonatomic)IBOutlet UIImageView *imgobj;
@property(strong,nonatomic)UIPinchGestureRecognizer *pinchobj;
@end

3) Write Following Code in ViewController.m :

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize imgobj,pinchobj;

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.pinchobj = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchselect:)];
    imgobj.userInteractionEnabled = YES;
    pinchobj.delegate = self ;
    
    [self.imgobj addGestureRecognizer:self.pinchobj];
}

-(void)pinchselect : (UIPinchGestureRecognizer *)recognizer
{
//    self.imgobj.transform = CGAffineTransformScale(self.imgobj.transform, recognizer.scale, recognizer.scale);
    
    
    CGFloat lastscaler =1;
    CGFloat factor =[(UIPinchGestureRecognizer *)recognizer scale];
    
    if (factor >1)
    {
        imgobj.transform=CGAffineTransformMakeScale
        (lastscaler + (factor-1),
         lastscaler +(factor-1));
        
    }
    else
    {
        imgobj.transform=CGAffineTransformMakeScale
        (lastscaler + (factor),
         lastscaler +(factor));
        
    }
    if (recognizer.state==UIGestureRecognizerStateEnded)
    {
        if (factor > 1)
            lastscaler+= (factor-1);
        else
            lastscaler+= factor;
        
        
    }

    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


Pen Gesture :

1 ) First Set View and Two Label (Text is null)            in The Storyboard :



2) Write Following Code in ViewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    UIView *view1;
    UIPanGestureRecognizer *panobj;
    
    UILabel *lblhori;
    UILabel *lblvert;
}

@property(strong,nonatomic)IBOutlet UIView *view1;
@property(strong,nonatomic)UIPanGestureRecognizer *panobj;

@property(strong,nonatomic)IBOutlet UILabel *lblhori;
@property(strong,nonatomic)IBOutlet UILabel *lblvert;

@end

3) Write Following Code in ViewController.m :

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize panobj,view1,lblhori,lblvert;

- (void)viewDidLoad
{
    [super viewDidLoad];
    panobj = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panselect:)];
    [self.view1 addGestureRecognizer:panobj];
    
    
}

-(void)panselect:(UIPanGestureRecognizer *)recognizer
{
    CGPoint touchLocation = [recognizer locationInView:self.view];
    self.view1.center = touchLocation;

    
    
    CGPoint velocity = [recognizer velocityInView:self.view];
    
    self.lblhori.text = [NSString stringWithFormat:@"Horizontal Velocity: %.2f points/sec", velocity.x];
    self.lblvert.text = [NSString stringWithFormat:@"Vertical Velocity: %.2f points/sec", velocity.y];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Rotate Gesture :

1 ) First Set One View in The Storyboard :



2) Write Following Code in ViewController.h :

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    UIView *view1;
    UIRotationGestureRecognizer *rotateobj;
}

@property(strong,nonatomic)IBOutlet UIView *view1;
@property(strong,nonatomic)UIRotationGestureRecognizer *rotateobj;

@end

3) Write Following Code in ViewController.m :

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize rotateobj,view1;

- (void)viewDidLoad
{
    [super viewDidLoad];
    rotateobj = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateselect:)];
    [self.view1 addGestureRecognizer:rotateobj];
    
    
}

-(void)rotateselect:(UIRotationGestureRecognizer *)recognizer
{
    self.view1.transform = CGAffineTransformRotate(self.view1.transform, recognizer.rotation);
    
    recognizer.rotation = 0.0;
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Saturday, 21 February 2015

Animation Images


Animation Images



1 ) First Add Two Frameworks :

- AVFoundation.Framework
- MediaPlayer.Framework

2 ) Add Images and Two Button in Storyboard :

3 ) Write This Code In ViewController.h :

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController
{
    AVAudioPlayer *audioobj;
    
}

@property(strong,nonatomic)IBOutlet UIImageView *imgobj;
@property(strong,nonatomic)NSMutableArray *arrobj;


- (IBAction)playvideo:(id)sender;

- (IBAction)stopvideo:(id)sender;

@end


4 ) Write This Code In ViewController.m :

@implementation ViewController
@synthesize imgobj,arrobj;

- (void)viewDidLoad
{
    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
}

- (IBAction)playvideo:(id)sender
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"mp3"];
    
    audioobj = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    
    [audioobj play];
    
     arrobj = [[NSMutableArray alloc] initWithObjects:
    
                           [UIImage imageNamed:@"win_1.png"],
                           [UIImage imageNamed:@"win_2.png"],
                           [UIImage imageNamed:@"win_3.png"],
                           [UIImage imageNamed:@"win_4.png"],
                           [UIImage imageNamed:@"win_5.png"],
                           [UIImage imageNamed:@"win_6.png"],
                           [UIImage imageNamed:@"win_7.png"],
                           [UIImage imageNamed:@"win_8.png"],
                           [UIImage imageNamed:@"win_9.png"],
                           [UIImage imageNamed:@"win_10.png"],
                           [UIImage imageNamed:@"win_11.png"],
                           [UIImage imageNamed:@"win_12.png"],
                           [UIImage imageNamed:@"win_13.png"],
                           [UIImage imageNamed:@"win_14.png"],
                           [UIImage imageNamed:@"win_15.png"],
                           [UIImage imageNamed:@"win_16.png"],nil];
    
    imgobj.animationImages = arrobj ;
    imgobj.animationDuration = 1;
    
    [imgobj startAnimating];
    
    
    
}

- (IBAction)stopvideo:(id)sender
{
    [audioobj stop];
    [imgobj stopAnimating];
    
}


@end

Audio & Video Player



Audio & Video Player


1 ) First Add Two Frameworks :

- AVFoundation.Framework
- MediaPlayer.Framework

2 ) Add Two Button in Storyboard :

3 ) Write This Code In ViewController.h :

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>

@interface ViewController : UIViewController

{
    AVAudioPlayer *audioplayer;
    MPMoviePlayerViewController *movieplayer;
}

- (IBAction)audioplay:(id)sender;

- (IBAction)videoplay:(id)sender;


@end

4 ) Write This Code In ViewController.m :

@implementation ViewController



- (void)viewDidLoad
{
    [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)audioplay:(id)sender
{
    
    NSString *path = [[NSBundle mainBundle]pathForResource:
                      @"Saturday_Saturday_(Humpty_Sharma_Ki_Dulhania(wapking.cc)" ofType:@"mp3"];
    movieplayer = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:path]];
    [self presentModalViewController:movieplayer animated:NO];
  //  [audioplayer play];
    

    
}

- (IBAction)videoplay:(id)sender
{
    
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"Movie" ofType:@"mp4" inDirectory:nil]];
    movieplayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    
    [self presentMoviePlayerViewControllerAnimated:movieplayer];
    
    
    
//    NSString *path = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"mp4"inDirectory:nil];
//    
// NSURL *movieURL = [NSURL fileURLWithPath:path];
//    
// movieplayer= [[ MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
//    
// [self presentMoviePlayerViewControllerAnimated:movieplayer];
    


}

@end

Sharing using SLComposeViewController

Sharing using SLComposeViewController



Hi Friends !!!  Here I am Trying My Best  for  how To share Image, URL andString In Facebook and Twitter with the help of SLComposeViewController. So,I think its may be very helpful to you,Because here I am Trying so simple & easy  language and method so that everyone can understand it very quickly.


 1 . ShareFile.h and ShareFile.m both files are given below. so download it from given below link and drag and drop in your project (keep both the copy of that file) . 

1)  Sharefile.h       Click Here :-    
2)  Sharefile.m     Click Here  :-     







2. Add below two framework in your project. (Click on Targets ->your app name -> and then the "Build Phase " tab. "Expand 'LinkBinary with Libraries" click the + button in the bottom left of the "Link Binary with Libraries" selection")
    -Accounts.framework
    -Social.framework

3. After adding above two framework now import ShareFile.h file. in your view     controller where you want to use.

If you want to Share your feeds In your Facebook through on your button click event Then refer the below code .

//When sharing Only String on Facebook
  [[ShareFile sharedSinglton] Fbsharing:@"Rathod's Demo"];

If Sharing  String and URL  on FaceBook

// When sharing String, URL on Facebook
[[ShareFile sharedSinglton] Fbsharing:@"Rathod's Demo" :[NSURLURLWithString:@"http://aniruddhsinhiostutorial.blogspot.in/"]];

If Sharing  String , URL and Image  on FaceBook

// When sharing String, URL and Image on Facebook
[[ShareFile sharedSinglton] Fbsharing:@"Rathod's Demo" :[NSURLURLWithString:@"http://aniruddhsinhiostutorial.blogspot.in/"] :[UIImage imageNamed:@"AniruddhSinh.png"]];

If you want to Share your feeds In your Twitter through on your button click event Then refer the below code .

//When sharing Only String on Twitter
[[ShareFile sharedSinglton] twittersharing:@"Rathod's Demo"];
If Sharing  String and URL  on Twitter

//When sharing String, URL on Twitter
[[ShareFile sharedSinglton]twittersharing:@"Rathod's Demo":[NSURLURLWithString:@"http://aniruddhsinhiostutorial.blogspot.in/"] :[UIImage imageNamed:@"AniruddhSinh.png"]];

If Sharing  String , URL and Image  on Twitter

// When sharing String, URL and Image on Twitter
[[ShareFile sharedSinglton] twittersharing:@"Rathod's Demo" :[NSURLURLWithString:@"http://aniruddhsinhiostutorial.blogspot.in/"] :[UIImage imageNamed:@"AniruddhSinh.png"]];

here you can share your feeds in your Facebook and Twitter with the help of above code . so enjoy every movement of programing. Thank you.

Note :- You Must Configure you Facebook and Twitter Account in your Device.

Collection View

Collection View


1 )  First set CollectionView in Your Storyboard ...


2 )  Write Coding in ViewController.h File...


@interface ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegate>
{
    __weak IBOutlet UICollectionView *objCollectionView;
    
}

@end


3 )  Write Coding in ViewController.m File...



@implementation ViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [objCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
    [objCollectionView setAllowsMultipleSelection:YES];
 
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 60;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    
    UICollectionReusableView *reusableview = nil;
    
    return reusableview;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(72, 72);
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier=@"Cell";
    
    UICollectionViewCell *objCollection=(UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    
    objCollection.backgroundView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d.png", [indexPath row] % 16]]];
    
    return objCollection;
    
}
- (void) selectCellForCollectionView:(UICollectionView *)collection atIndexPath:(NSIndexPath *)indexPath
{
    [collection selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone];
    [self collectionView:collection didSelectItemAtIndexPath:indexPath];
}

- (void) deselectCellForCollectionView:(UICollectionView *)collection atIndexPath:(NSIndexPath *)indexPath
{
    [collection deselectItemAtIndexPath:indexPath animated:YES];
    [self collectionView:collection didDeselectItemAtIndexPath:indexPath];
}

@end

XML Parsar ( GdataXml parser )

XML Parsar

Xml Example :

Hi Friends !!!  Here I am Trying My Best To explain how Use  Xml  In IOS. So,I think its may be very helpful to you, Because here I am Trying so simple & easy  language and method so that everyone can understand it very quickly.
Here xml Example using the GdataXml parser..

1. First put the xml folder in your new project ...(that given below) in this Folder include the AsiHttp ,GdataXml ,Rss ,Singleton Folders.

Xml folder

2. xml folder contain all the non ARC file so set the flag (-fno-objc-arc ) in compile sources.
     (go to Build Phases --> compile sources ---> set flag to -fno-objc-arc)

3. add following  framework in your project
   -security.framework
   -systemConfiguratin.framework
   -libz.dylib
   -MobileCoreServices.framework
   -CFNetwork.framework
   -libxml2.dylib

4. inser new  path in header searchpath.(go Build Setting -> Search path-->Header Search Paths)

/usr/include/libxml2 

and  finally build your project..(cmd +b). (if error occur than see and check again all step).
so no error occur than ...

your viewcontroller.h

//  ViewController.h
//  xml demo
//  Created by Ilesh panchal on 
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
    NSMutableArray *allEntries;
    NSOperationQueue *queue;
    NSMutableArray *arrData;
}
@property (nonatomic,strong) NSMutableArray *allEntries;
@property (nonatomic,strong) NSOperationQueue *queue;
@property (nonatomic,strong) NSMutableArray *arrData;
@end

and view controller .m flle put the following method..
--- Import following files

#import "ASIHTTPRequest.h"
#import "GDataXMLNode.h"
#import "GDataXMLElement-Extras.h"
#import "NSDate+InternetDateTime.h"
#import "NSArray+Extras.h"
#import "Singleton.h"
In viewDidLoad Method put this file in that..
    arrData=[[NSMutableArray alloc] init];
    self.allEntries = [NSMutableArray array];
    self.queue = [[NSOperationQueue alloc] init];
    // changge your url in this..
    NSURL *url = [NSURL    URLWithString:@"http://www.sandesh.com/cms/xml/Ahmedabad%20District.xml"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [_queue addOperation:request];
copy the following method ..
- (void)parseFeed:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
    if ([rootElement.name compare:@"rss"] == NSOrderedSame) {
        [self parseRss:rootElement entries:entries];
    } else {
        NSLog(@"Unsupported root element: %@", rootElement.name);
    }
}
- (void)requestFinished:(ASIHTTPRequest *)request {
  [_queue addOperationWithBlock:^{
        NSError *error;
        GDataXMLDocument *doc = [[GDataXMLDocument alloc]initWithData:[request responseData] options:0 error:&error];
        if (doc == nil) {
            NSLog(@"Failed to parse %@", request.url);
        } else {
            NSMutableArray *entries = [NSMutableArray array];
            [self parseFeed:doc.rootElement entries:entries];
            // [[NSOperationQueue mainQueue] addOperationWithBlock:^{ }];
        }
    }];
}
- (void)requestFailed:(ASIHTTPRequest *)request {
    NSError *error = [request error];
    NSLog(@"Error: %@", error);
   }
and finally add the following method and modify your tag is different ..
- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries
{   
     //here my first tag in the rss fied ...
    NSArray *channels = [rootElement elementsForName:@"channel"];
       // NSLog(@"%@",channels);
    for (GDataXMLElement *channel in channels)
    {   
        NSArray *items = [channel elementsForName:@"item"];
        //NSLog(@"%@",items);
        for (GDataXMLElement *item in items) 
    {
     NSString *articleTitle = [item valueForChild:@"title"];
     NSLog(@"%@",articleTitle);
 //  NSString *strDes = [item valueForChild:@"description"];
 //  NSString *strLink =[item valueForChild:@"link"];
//  NSString *articleDateString = [item valueForChild:@"pubDate"];

   NSString *strcity = [(GDataXMLElement *) [locations attributeForName:@"city"] stringValue];      

 // if data is in Custom  tag then Get data using This Coding :-[ <yweather:location city="Rudersdorf" region="OO" country="Austria"/> ]


        }

    }
}

Calculator


1 )  First Of All Set Your StoryBoard Like This ...



2 ) Then Set Button Tag From The Property Window .... 


         Set    1   to   9   tag as it is Number 
         Set    0   to  10
         Set   +   to   11
         Set   -   to    12
         Set   *   to    13
         Set   /    to    14
         Set   %   to   15
         Set   =   to    16
         Set   C   to   17


3)   Write Code In ViewController.h File Like This ...



@interface ViewController : UIViewController<UITextFieldDelegate>
{
    int a;
    int b;
    int c;
}

@property (strong, nonatomic) IBOutlet UITextField *textfield;
- (BOOL)textFieldShouldReturn:(UITextField *)textField;   
@end


4)   Write Code In ViewController.m File Like This ...


@implementation ViewController
@synthesize textfield;
- (void)viewDidLoad
{
    [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)genralmethod:(UIButton *)sender
{
    textfield.text=[textfield.text stringByAppendingString:sender.titleLabel.text];
}
- (IBAction)genralopmethod:(UIButton *)sender
{
     a=[textfield.text intValue];
    if (sender.tag==11)
    {
        c = sender.tag;
        textfield.text = @"";
      
    }
    else if (sender.tag==12)
    {
        c = sender.tag;
        textfield.text = @"";
        
    }
    else if (sender.tag==13)
    {
        c = sender.tag;
        textfield.text = @"";
    }
    else if (sender.tag==14)
    {
        c = sender.tag;
        textfield.text = @"";
    }
    else if (sender.tag==15)
    {
        c = sender.tag;
        textfield.text = @"";
    }
    else if (sender.tag == 17)
     {
        textfield.text = @"";
    }
   
}

- (IBAction)eq:(UIButton *)sender
{
    if (sender.tag==16)
   {
       switch (c) {
           case 11:
               b = a + [textfield.text intValue];
               textfield.text=[NSString stringWithFormat:@"%d",b];
               break;
               case 12:
               b = a - [textfield.text intValue];
               textfield.text=[NSString stringWithFormat:@"%d",b];
               break;
               case 13:
               b = a * [textfield.text intValue];
               textfield.text=[NSString stringWithFormat:@"%d",b];
               break;
               case 14:
               b = a / [textfield.text intValue];
               textfield.text=[NSString stringWithFormat:@"%d",b];
               break;
               case 15:
               b = a % [textfield.text intValue];
               textfield.text=[NSString stringWithFormat:@"%d",b];
               break;
               
           default:
               break;
       }
       
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{

    [textfield resignFirstResponder];
    return YES;
}

@end