Search This Blog

Friday, November 29, 2013

Git commands for iphone Apps

Set up Git from the Command-line


git clone "server url"   //This will create a new local repository which is a clone of the server repository. Along with all its branches.


git init 
git log
git diff
git status
git commit -m "first commit"
git commit -a -m "made some change"
git branch
git commit --amend //This will merge the new commit to the existing commit.
git checkout --<file name> //This will revert the changes we did in the file to the last commit state.


git config --global user.name "radha"  //Changing the User Name
git config user.name    //To Display the User NAME



git branch  //list all branches
git branch test  //new branch
git checkout test //switch branch
git checkout -b test  //single cmd to do above 2 commands



git merge newBranch //wen ever ur merging have to go to current branch and then merge

git branch -d newBranch  //deleting the branch

git remote -v  // tp show remote url
git remote add [short name]  [url]  //add more repositories

Fork a Repository:
   ●  This feature of GitHub allows us to make a mutable copy of a read only public repository into our own GitHub repository and work with it. 
  • ●  This feature also allows us to stay in sync with the original repository by simple git pull/ git fetch commands. 
-----
Adding Remote
git remote add nu https://github.com/xxxxx.git


All available Branches in all remotes
git branch -a

Fetch Code from particular Remote
git fetch nu

Going into Remote Branch
git checkout -t origin/development

Merging the nu remote code to ur development Branch
git merge krishna/development


IMPortent Commands:
To get the Other Branch code and Merge to your Branch
1.Commit your Code
2.Fetch other Branch Code
3.Merge to your Branch

git commit -am "Commit Message"
git fetch krishna   //krishna is the Remote name of other Developer
git merge krishna/brnach3       // remote name/Branch Name
----


To Push Your Code to Server:
1.Commit Your Code
2.Push Code

git commit -am "Commit Message"
git push origin ARC

----





     






Thursday, November 28, 2013

Custom Audio Player for iPhone SDK


Audio Player

.h

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

@interface ViewController : UIViewController
{
    AVAudioPlayer *player;
    IBOutlet UISlider *volumeSlider,*durationSlider;
}

-(IBAction)durationChange:(id)sender;
-(IBAction)volumeChanged:(id)sender;
-(IBAction)stop:(id)sender;
-(IBAction)play:(id)sender;
@end

.m

#import "ViewController.h"
@implementation ViewController


-(IBAction)volumeChanged:(id)sender
{
    [player setVolume:volumeSlider.value];
}


-(IBAction)stop:(id)sender
{
    if(player)
        [player stop];
}
-(IBAction)durationChange:(id)sender;
{
    [player setCurrentTime:durationSlider.value];
}

-(IBAction)play:(id)sender;
{
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"123-05 No Money No Money" ofType:@"mp3"];
    NSLog(@"file path is %@",filePath);
    
    //converting file Path to the url
    NSURL *url  = [NSURL fileURLWithPath:filePath];
    
    if(!player)
    player = [[AVAudioPlayer allocinitWithContentsOfURL:urlerror:nil];
    
    
    float totalDuration = [player duration];
    [durationSlider setMaximumValue:totalDuration];
    
    float currentDuration = [player currentTime];
    
    
    
    [player setDelegate:self];
    
    //set Volume
    [player setVolume:1];
    
    [player prepareToPlay];
    [player play];
}
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
    NSLog(@"audioPlayerDidFinishPlaying called");

}
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error
{
    NSLog(@"audioPlayerDecodeErrorDidOccur called");
}

@end

Touches Sample in iPhone SDK


Touches

.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIAlertViewDelegate,UIActionSheetDelegate>
{
  
}

-(IBAction)cleanAll:(id)sender;
@end


.m

#import "ViewController.h"

@implementation ViewController


-(IBAction)cleanAll:(id)sender;
{
    NSArray *subViewsArray = [self.view subviews];
    for (int i=0; i<[subViewsArray count]; i++)
    {
        UIView *vi = [subViewsArray objectAtIndex:i];
        if(![vi isKindOfClass:[UIButton class]])
           [vi removeFromSuperview];
    }


}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"touchesBegan called");
   
    UITouch *touch = [touches  anyObject];
    CGPoint pnt = [touch locationInView:self.view];
    NSLog(@"touch point is (%0.0f,%0.0f)",pnt.x,pnt.y);
    
    UILabel *lbl = [[UILabel allocinitWithFrame:CGRectMake(pnt.x, pnt.y33)];
    [lbl setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:lbl];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
      NSLog(@"touchesMoved called");
    UITouch *touch = [touches  anyObject];
    CGPoint pnt = [touch locationInView:self.view];
    NSLog(@"touch point is (%0.0f,%0.0f)",pnt.x,pnt.y);
    
    UILabel *lbl = [[UILabel allocinitWithFrame:CGRectMake(pnt.x, pnt.y33)];
    [lbl setBackgroundColor:[UIColor redColor]];
    [self.view addSubview:lbl];


}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
   NSLog(@"touchesEnded called");
}

@end

How to Implement Web View


UIWebView

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

@interface ViewController : UIViewController
{
    IBOutlet UIWebView *webView1;
    IBOutlet UITextField *txtField;

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

@end



.m

#import "ViewController.h"
@implementation ViewController


-(IBAction)goClick:(id)sender;
{
    NSString *str = txtField.text;
    NSString *urlString;
    NSRange range = [str rangeOfString:@"http://"];
    if(range.location == NSNotFound)
    {
        urlString = [NSString stringWithFormat:@"http://%@",str];
     }
    else
        urlString = str;
    
    txtField.text = urlString;
    
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView1  loadRequest:request];
    [webView1 setScalesPageToFit:YES];
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidStartLoad called");
    

}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
   NSLog(@"webViewDidFinishLoad called");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    UIAlertView *alert = [[UIAlertView allocinitWithTitle:@"Error"message:[error localizedDescriptiondelegate:nilcancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
  NSLog(@"didFailLoadWithError called and error info is %@",[error userInfo]);
}

-(void)viewDidLoad
{
    //Url loading in the WebView
    NSString *urlString = @"http://www.google.com";
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView1 setDelegate:self];
    [webView1  loadRequest:request];
    [webView1 setScalesPageToFit:YES];
    

    /*
    //HTML Content
    [webView1 loadHTMLString:@"<html><body><h1>Hello World</h1></body></html>" baseURL:nil];
    

    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"b" ofType:@"png"];
    [webView1 loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
    
    */
}

@end