Search This Blog

Saturday, December 21, 2013

App Sore Submission and Device Execution and .ipa File Creation

App Sore Submission and Device Execution and .ipa File Creation

1.Setting up for the device Execution
2.ipa file building
3.App Store submission


1.Setting up for the device execution:
  a.CSR generation
  b.uploading CSR to developers portal and download the Developers profile
  c.Adding Devices
  d.Creating App Id
  e.Generate Provisioning Profile for Debugging the App
  f.Generate Distribution for the .ipa File Generation
  g.Generate App Store Profile for the App Store Submission


 a.CSR generation:
     key chain Access App --> Certificate Assistent--> Request a Certificate from certificate Authority --> save to disk option and give the Email Address --> Continue --> Done
b.uploading CSR to developers portal and download the Developers profile
    goto www.developer.apple.com--->iOS dev center -->login -->iOS Provisioning portal--> Certificates --> Request Certificate --> choose file--> Upload ur CSR File which is create from key chain in ur desktop.
  And Click on the refresh button and Download the Developer identity.
 And also download the WWDR Certificate 

Click on the Distribution Tab -->Request Certificate --> choose file--> Upload ur CSR File which is create from key chain in ur desktop.
  And Click on the refresh button and Download the Distribution identity.
 And also download the WWDR Certificate 

c.Adding Devices

  //Getting UDID
  1.installing udid app in Device 
  2.Connect to iTunes and go to summary tab
  3.goto organizer in XCODE and select Device tabs

   goto www.developer.apple.com--->iOS dev center -->login -->iOS Provisioning portal-->Devices--> Add Device--> give Device name name and UDID
  Note : You can get the udid from the UDID App in the App Store or else connect your device and open itunes--> Summary --> copy udid

d.Creating App Id
    goto www.developer.apple.com--->iOS dev center -->login -->iOS Provisioning portal-->App Id--> Create new App Id --> give app name and identifier like "com.rapid.abc"  (abc is the application name and rapid is the company name)

Note : give (com.*)


e.Generate Provisioning Profile for Debugging the App
1.Provisioning Profile  —> Used for Debugging 
2.Distribution Profile    —> To Distribute the App
3.App Store Profile       —> To Send to App Store

   goto www.developer.apple.com--->iOS dev center -->login -->iOS Provisioning portal-->Provisioning Profile--> Development --> Add new Profile --> Give profile name and Selct the App id and select the Devices and Submit--> and then click on download button.

After download the profile double click on the profile and then it will goto XCODe and it should give green colour tick mark.


g.Generate App Store Profile for the App Store Submission

   goto www.developer.apple.com--->iOS dev center -->login -->iOS Provisioning portal-->Provisioning Profile-->Distibution-->Add new Profile -->Select App Store or ADhoc Distribution -->Give profile name and Select the App id and select the Devices and Submit--> and then click on download button.

After download the profile double click on the profile and then it will goto XCODe and it should give green colour tick mark.


2.ipa file building

      Open XCODe Project and the goto Build Settings --> Code Signing --> Select the Latest Enabled profiles of hrs in all 4 sections -->  and then Click on Product button in the Status Bar opn MAC--> Clean

And again Product--> Archieve --> Select the Distribute button--> Distribution ---> save on ur MAC.


3.App Store submission
1. Login to https://itunesconnect.apple.com/ 
2. Enter the login credentials.
3. Click on Manage your applications
4. Add New App --> Give the App Name --> Select the build identifier --> and click on next.
5.Give the Description,keywords,Select the Category and subcategory,Screen shots(640*960 and 640*1136),icon files(1024*1024),Give test id and pwd if ur app having the login screen.--> submit
6.And Select your App--> view details --> click on upload binary button (Your app colour changed to yellow)


7.Open XCODE Project select the App Store profile and Deployment target
8.Click On Product button on the top --> Clean and Again Product button click and Archive
9.Select the Distribute button--> App Store Distribution --> give id and pwd --> done.



Thursday, December 12, 2013

NSRunLoop

A run loop is an abstraction that (among other things) provides a mechanism to handle system input sources (sockets, ports, files, keyboard, mouse, timers, etc).
Each NSThread has its own run loop, which can be accessed via the currentRunLoop method.
In general, you do not need to access the run loop directly, though there are some (networking) components that may allow you to specify which run loop they will use for I/O processing.
A run loop for a given thread will wait until one or more of its input sources has some data or event, then fire the appropriate input handler(s) to process each input source that is "ready.".

After doing so, it will then return to its loop, processing input from various sources, and "sleeping" if there is no work to do.

Wednesday, December 11, 2013

ARC concepts

ARC

Automatic Reference Counting (ARC) is a compiler feature that provides automatic memory management of
Objective-C objects. Rather than having to think about retain and release operations, ARC allows you to
concentrate on the interesting code, the object graphs, and the relationships between objectsin your application

   ARC works by adding code at compile time to ensure that objects live as long as necessary, but no longer.
Conceptually, it follows the same memory management conventions as manual reference counting by adding the appropriate memory management
calls for you.



- (void)contrived {
Person *aPerson = [[Person alloc] init];
[aPerson setFirstName:@"William"];
[aPerson setLastName:@"Dudney"];
[aPerson setYearOfBirth:[[NSNumber alloc] initWithInteger:2011]];
NSLog(@"aPerson: %@", aPerson);
}

ARC takes care of memory management so that neither the Person nor the NSNumber objects are leaked.

->You cannot explicitly invoke dealloc, or implement or invoke retain, release, retainCount, or
autorelease.
The prohibition extends to using @selector(retain), @selector(release), and so on.

->You cannot use NSAllocateObject or NSDeallocateObject.
->You cannot use object pointers in C structures.
->● You cannot use NSAutoreleasePool objects.
ARC provides @autoreleasepool blocks instead. These have an advantage of being more efficient than
NSAutoreleasePool.

->● You cannot use memory zones.
There is no need to use NSZone any more—they are ignored by the modern Objective-C runtime anyway.
->You cannot give an accessor a name that begins with new. This in turn means that you can’t, for example,
declare a property whose name begins with new unless you specify a different getter:

->The keywords weak and strong are introduced as new declared property attributes, asshown in the following
examples.

->// The following declaration is a synonym for: @property(retain) MyClass *myObject;
@property(strong) MyClass *myObject;

->// The following declaration is similar to "@property(assign) MyClass *myObject;"
// except that if the MyClass instance is deallocated,
// the property value is set to nil instead of remaining as a dangling pointer.
@property(weak) MyClass *myObject;


->Under ARC, strong is the default for object types

VariableQualifiers
__strong
__weak
__unsafe_unretained
__autoreleasing



 ● __strong is the default. An object remains “alive” as long as there is a strong pointer to it.
 ● __weak specifies a reference that does not keep the referenced object alive. A weak reference is set to
nil when there are no strong references to the object.
Transitioning to ARC Release Notes
ARC Overview

 ● __unsafe_unretained specifies a reference that does not keep the referenced object alive and is not
set to nil when there are no strong references to the object. If the object it references is deallocated, the
pointer is left dangling.
 ● __autoreleasing is used to denote argumentsthat are passed by reference (id *) and are autoreleased
on return.



Eg:
NSString * __weak string = [[NSString alloc] initWithFormat:@"First Name: %@",
[self firstName]];
NSLog(@"string: %@", string);


Although string is used after the initial assignment, there is no other strong reference to the string object
at the time of assignment; it is therefore immediately deallocated. The log statement shows that string has
a null value. (The compiler provides a warning in this situation.)


Eg 2:
NSError *error;
BOOL OK = [myObject performOperationWithError:&error];
if (!OK) {
// Report the error.
// ...
However, the error declaration is implicitly:




NSError * __strong e;
and the method declaration would typically be:
-(BOOL)performOperationWithError:(NSError * __autoreleasing *)error;


The compiler therefore rewrites the code:
NSError * __strong error;
NSError * __autoreleasing tmp = error;
BOOL OK = [myObject performOperationWithError:&tmp];
error = tmp;
if (!OK) {
// Report the error.
// ...
The mismatch between the local variable declaration (__strong) and the parameter (__autoreleasing)
causesthe compiler to create the temporary variable. You can get the original pointer by declaring the parameter
id __strong * when you take the address of a __strong variable. Alternatively you can declare the variable
as __autoreleasing.


Patterns for Managing Outlets Become Consistent Across Platforms
The patterns for declaring outlets in iOS and OS X change with ARC and become consistent across both
platforms. The pattern you should typically adopt is: outletsshould be weak, except for those from File’s Owner
to top-level objects in a nib file (or a storyboard scene) which should be strong

Stack Variables Are Initialized with nil
Using ARC,strong, weak, and autoreleasing stack variables are now implicitly initialized with nil. For example:
- (void)myMethod {
NSString *name;
NSLog(@"name: %@", name);
}
will log null for the value of name rather than perhaps crashing.


iOS 7 icon sizes

DevicesiOS 6 size (in pixel)iOS 7 size (in pixel)
iPhone Non Retina57 x 57not available
iPhone Retina114 x 114120 x 120
iPad Non Retina (mini and 2nd gen)72 x 7276 x 76
iPad Retina144 x 144152 x 152

iOS 7 icon sizes

DevicesiOS 6 size (in pixel)iOS 7 size (in pixel)
iPhone Non Retina57 x 57not available
iPhone Retina114 x 114120 x 120
iPad Non Retina (mini and 2nd gen)72 x 7276 x 76
iPad Retina144 x 144152 x 152

Wednesday, December 4, 2013

UIRefreshController

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl setFrame:CGRectMake(0, 0, 320, 10)];

    [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    NSString *title  =@"Pull down to refresh";
    NSMutableAttributedString *titleAttString =  [[NSMutableAttributedString alloc] initWithString:title];
    
    [titleAttString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica" size:12.0f] range:NSMakeRange(0, [title length])];

    refreshControl.attributedTitle = titleAttString;
    refreshControl.tintColor = [UIColor grayColor];

    //UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50,10)];
    //[lbl setText:title];
    refreshControl.accessibilityLabel = title;


    [objTable addSubview:refreshControl];

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