Thursday, July 21, 2011

Steps to avoid app rejection from Apple


An app idea or product app takes much of time and money investment to get into app world existence. The major hurdle to it’s success could be Apple’s review process. There can be numerous reasons for Apple’s rejections for your app. With our superior knowledge of iOS apps development since the day Apple launched their SDK, we are able to gain valuable insights into Apple’s review process.

This will help:

1. Developers to save their precious time and efforts.
2. Let you plan for a better user experience which is the key reason behind all the app store guidelines.

There are few key points which every iPhone/iPad developer should know when developing an app for Apple devices.

Key things to avoid Apple’s app rejection:

1. Bugs/Crashes- The most common reason for any app to get rejected are freezing and frequent crashes. Make sure you test it on multiple devices, different OS versions and specifically under varying network conditions. Peer-to-peer reviews/testing done by developers would certainly help. If your app crashes or doesn’t respond during the app review by Apple’s testing team then it will definitely be rejected.

2. Code Download- You cannot create an app that downloads and executes code that was not present in the app bundle submitted to Apple.

3. Similar Icons- The app store 512×512 icon should be same as the app’s 57×57 icon. Even though there is no such direct rule in contract/agreement with Apple, its their store and they make the rules for reviews. If your app’s icon on phone and app store icon do not match, Apple will state having un-matching icons to reject the app.

4. Network Connectivity- You must notify the user if network is unavailable. Just having the spinning busy icon display and a message saying “trying to connect” is against the guidelines. Proper message is needed at all the screens to convey clear message if network is not available after certain period of time. Many developers put their connectivity checks on Apple’s Reachability code, which is using that sample code for the wrong purpose. If you need to get data from a specific server, then try to download some data from that domain.

5. “Free+Paid” apps- Apple reported to few developers that app may get rejected, if it contains visually disabled buttons, prompting the user to upgrade for the full version or displaying the price of full version in the Free version. So, iPhone developers must ensure that they follow all the rules.

6. Consistent Button Images- If an iPhone developer wants to use Apple’s existing image for his button then see that functions are identical because you can use a standard button in a non-standard way if your app is providing a “immersive environment” so it is better to create your own button. If there are any variations with function then again Apple might reject the app.
It is always advisable for an iPhone developer to use their own custom buttons in the app.

7. iOS version support- If you plan on submitting and app which runs with 3.0 and higher versions, you should be sure that it works perfectly on all the versions from the iOS 3.0 to the most current version. Apple will test it with the latest version to see the potential of the app but if the app fails to prove itself Apple will definitely rejected your app.

8. Transactions outside The App Store- Apple do not allow developers to conduct any transaction/business outside the app store. In App purchases are the recommended way to implement these transaction. Recent announcement to allow outside payment transaction with certain restriction and Apple’s percentage take from money for the same is trickier and would take more time to settle down in business plan of apps sale.

9. Private APIs- Apple strictly reject apps which are implementing programs using Private APIs. Apple has scripts that can scan your app codes for violations. If you want to prevent app rejection from app store make sure you read the developer guidelines carefully before implementing any API marked private by Apple.

10. Popovers- It is definitely not recommended to launch one popover from within another popover. The iPad Human Interface Guidelines clearly provides this information that only one popover element should be shown onscreen at a time.

There can be many more reasons behind Apple’s rejection of any iOS app. However, the list provides very obvious ones.

I hope that this post will help you in avoiding the app rejection from apple and saving your time and efforts in development. Happy iCoding and have a great Day.

Wednesday, July 20, 2011

Saving your private key and transferring to other system

It is critical that you save your private key somewhere safe in the event that you need to develop on multiple computers or decide to reinstall your system OS. Without your private key, you will be unable to sign binaries in Xcode and test your application on any Apple device. When a CSR is generated, the Keychain Access application creates a private key on your login keychain. This private key is tied to your user account and cannot be reproduced if lost due to an OS reinstall. If you plan to do development and testing on multiple systems, you will need to import your private key onto all of the systems you’ll be doing work on.
  1. To export your private key and certificate for safe-keeping and for enabling development on multiple systems, open up the Keychain Access Application and select the ‘Keys’ category.
  2. Control-Click on the private key associated with your iOS Development Certificate and click ‘Export Items’ in the menu. The private key is identified by the iOS Developer: <First Name> <Last Name> public certificate that is paired with it.
  3. Save your key in the Personal Information Exchange (.p12) file format.
  4. You will be prompted to create a password which is used when you attempt to import this key on another computer.
  5. You can now transfer this .p12 file between systems. Double-click on the .p12 to install it on a system. You will be prompted for the password you entered in Step 4.


    Export Private Key

Tuesday, July 19, 2011

Performing actions on specific image touch

Sometimes it may happen that you need to touch the images and on the touch of a specific image you need to perform some action.

So in todays post we shall discuss how to do this.

Design Phase: For this demo i have took two image views containing the images of spider man and super man and on the touch of each image i shall display a alertview.



Step 1: open Xcode and create a windows based application and add the UIViewController subclass file into it with an appropriate name, now create the view just like the above image of the design phase containing two instance of UIImageView class.

Step 2: Once you have completed the design now its time to add the instance method of the UIResponder class called as the touch began

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event


Step 3: It's time to give body to that method, the entire code looks like this

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
pnt = [[touches anyObjectlocationInView:self.view];
if (CGRectContainsPoint(SpiderManImageView.framepnt)) 
{
UIAlertView *spiderManAlertView = [[UIAlertView alloc]initWithTitle:@"iPhone by radix" message:@"Spider man image touched" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
[spiderManAlertView show];
[spiderManAlertView release];
}
else if(CGRectContainsPoint(SupermanImageView.framepnt))
{
UIAlertView *superManAlertView = [[UIAlertView alloc]initWithTitle:@"iPhone by radix" message:@"Super man image touched" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
[superManAlertView show];
[superManAlertView release];
}
}


Code Explanation: The CGRectContainspoint is a function which accepts 2 parameter one is the rectangle who's points are to be examined and other is the parameter for the examiner point that will be checked and then just apply a simple if clause. The pnt is a variable of type CGPoint which contains the information about the point where the user has currently touched.

Step 4: Select the appDelegate.m file and this view to the iPhone window and then run the application.

Step 5: When you run the application you will get the final output.




I hope that this post was helpful to you, if you have any queries then kindly let me know until then happy iCoding and have a great Day.

Wednesday, July 13, 2011

Removing the Provisioning profile from iTunes.

Their might be scenarios in your iPhone app development career when you would require the need to remove the provisioning profile from the iTunes.


Given below are the steps that are required to remove the provisioning profile from the iTunes.


Step 1: Open Finder and select the Places menu and from the places menu select the Home user the one with the home logo.


Step 2: Now select the library folder this folder contains one sub folder with the name Mobile Device.


Step 3: Go inside the Mobile Device folder and inside that folder you will find a folder with the name provisioning profile which would contain the list of provisioning profile that are present in the itunes, remove the selected profile or all of them as per your need and you are done.


The entire view looks like this 






I hope that this method would be useful to you some how in the future, until then happy iCoding and have a great Day.

Tuesday, July 12, 2011

Vibrate the iPhone device


In this post we will learn how to vibrate the iOS device.
Note : This demo app will not work on the iPod touch as it is not capable of vibrating, so make sure that you deploy this demo app in a iPhone device.
Design Phase: For this application I thought when the user will touch the screen the device must vibrate with an alert view being displayed which says that the screen is touched. Here’s a view at the final output.

Step 1: Open Xcode create a windows based application and give a name to your project and then add a UIViewController subclass to your project with the name myViewController, now you will see that there are two files added into your project with the name myViewController.h and myViewController.m.
Step 2: Inorder to vibrate the device you need to add a framework called as the AudioToolBox framework , and if you are using the latest Xcode SDK i.e 4.2 then the steps to add a framework are somewhat different so lets have a look on how to add a framework with the lastst Xocde SDK.
a.     Select the Xcoce project file and then you will see a view somewhat like this



b.     From their select the target file and press the build phases their you will see the link libraries please select it and press the down arrow


c.     Their your will see the set of frameworks that are present into your application also you may see the add button.
d.     Press the add button this will open a popup with a list of frameworks that are present into your applications please select the appropriate framework of your choice and then press the done button, in this case you will select the AudioToolKit framework.


Step 3: Now please select the myViewController.m file now as per our logic here we have to vibrate the device on the touch of the screen so in that case please copy the touchbegn function from the UIResponder class and paste it inside the myViewControlller.m file. Here’s a look at the body of the function
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
   
     // Displaying the alert view
     UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Screen Touched!"
                          message:nil
                          delegate:nil
                          cancelButtonTitle:nil
                          otherButtonTitles:@"OK", nil];
     [alert show];
    [alert release];
   
}

Code Explanation: There is a function present in the audioToolkit which vibrates the device for you and for that you must supply in the parameter as given above and that’s all you will require. In the next line I am just displaying the alert view which says screen touched that’s all.
Step 4: Now its time to add the view to the iPhone window so for doing that please select the appDelegate.m file and add the following code to present the view into the iPhone window
#import "VibrateDeviceAppDelegate.h"
#import "myViewController.h"
@implementation VibrateDeviceAppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.
myViewController *obj =[[myViewController alloc]init];
[window addSubview:obj.view];
    
    [self.window makeKeyAndVisible];
    
    return YES;
}
Step 5: Deploy this application into the iPhone device and touch the screen you will see that the when you touch the screen the device vibrates and displays the alert view, and if you need any guidance in deploying the app then refer this post. 

Monday, July 4, 2011

Clearing misconception between the android os and the iOS


Article on Mobile OS war!
By  Faisal Mohammed (faisal1600@gmail.com)


This article is written by one of my best friend Faisal he is a technical geek on mobile technology and he earlier wrote this article explaining the difference between iOS and android and it was his idea to get this on my blog because many people are having the misconception that the android os is actually a copy of the iOS, so here's a word from my friend to you all explaining the actual difference between them. 







There’s a common misconception/hypocrisy that Android copied iOS .....

Bt the truth is Android is not a derivative/copy/inspired of/from iOS. It is a modified version of the Linux Kernel, which was initially released in 1991...and iOS is developed after MAC OS and released in 2007,which is so very different from LINUX The development of android is from the year 2003 by a company called 'Android Inc' and two years later it was acquired by Google.

When people say Android is copied from iOS , then they fail to note the biggest difference.....Android is an FREE & OPEN SOURCE, while iOS works in a closed eco system where the program files (application system files are hidden from the end user) ,so then tell me how come.. A ''copied'' thing is so vastly different from the supposed source.


One more big difference in both the OS is the notification bar. Android has this bar which slides down anywhere in the UI to give information about the happenings in the device, very user friendly bar on the top of the screen, which iOS has just incorporated in its 5th iteration.

If we talk about the UI (user interface)...then yes it has similarities just on the icons visual front. But the whole working and eco system is different  and Android unlike iOS is modifiable and highly widget based so the manufacturers take liberty of skinning the whole UI according to their customer base.eg Samsung uses its 'Touchwiz’ layout...have a look at HTC SENSE...which is android...and very very different from iOS and stock android...

If we draw an analogy with Motorcycles, every motorcycle has the brake on the right foot, gear lever on left, throttle on right hand, clutch on left etc. And all of the engines work on the principle of fuel combustion. So we don’t say that they copy each other, do v? So same way the UIs are made according to that. 

The basic idea of a touch screen UI is to make it as thumb/finger friendly as possible. So if the icons are as big as an iOS, Then it is for being user friendly & not being a copy , because it looks good and this Layout of iOS has been similarly used way long before iOS...have a look at BREW mobile OS, Symbian UIQ which existed much before iOS came into existence.

Having used both the OS'es' for a considerable time...i can say iOS is more refined, chivalrous, simple and glossy. On the other hand ANDROID is so damn powerful that it gives u the whole control of it in your palm, so more possibilities.


Apart from these two OS. Symbian has got boring with age but the way it runs its software at on a comparably less hardware from its competitors is commendable. Symbian’s new ANNA update doesn’t change anything.
Nokia’s new MEE-GO still looks bleak as it is in its infancy stage and yet to see developers support like its counter parts iOS and Android.
RIM BB OS is the pioneer OS of connectivity and speed of processing the internet on it. 


PS: Why don’t we say Windows is ''copied'' from Macintosh OS? Windows came way after Mac and has an alleged history of inspiration from Mac, so we should be ridiculing windows, rite? But we don’t, coz vast majority uses Windows and not MAC.!!!....think.....???

Info on Split view Controller


What is split view controller:
The UISplitViewController class is a container view controller that manages the presentation of two side-by-side view controllers. You use this class to implement a master-detail interface, in which the left-side view controller presents a list of items and the right-side presents details of the selected item. Split view controllers are for use exclusively on iPad devices.
A split view controller interposes itself between the application’s window and its child view controllers. As a result, all messages to the visible view controllers must flow through the split view controller. This works generally as you might expect and the flow of messages should be relatively intuitive. 

For example, view appearance and disappearance messages are sent only when the corresponding child view controller actually appears on screen. Thus, when a split view controller is first displayed in a portrait orientation, it calls the viewWillAppear: and viewDidAppear: methods of only the view controller that is shown initially. The view controller that is presented using a popover does not receive those messages until the popover is shown or until the split view controller rotates to a landscape orientation.
The UISplitViewController class is a container view controller that manages two panes of information. The first pane has a fixed width of 320 points and a height that matches the visible window height. The second pane fills the remaining space. In a landscape orientation, the split view controller presents the two panes side-by-side with a small divider separating them. 
Landscape mode

In a portrait orientation, the split view controller shows only the second, larger pane and provides a toolbar button for displaying the first pane using a popover,
Portrait Mode

The easiest way to integrate a split view controller into your application is to start from a new project. The Split View-based Application template in Xcode provides a good starting point for building an interface that incorporates a split view controller. Everything you need to implement the split view interface is already provided.
SplitViewController Template

In the next post i will explain you how to use the split view controller.

UISplitViewController Tutorial


In this post we will learn on how to use the iPad split view controller.

Note: This post was voted high by the members of iPhone by radix on the facebook group so I thank all of them for sharing their views.

Before beginning with this post i would request you to read about the split view controller from my earlier post first and then begin with this post.

Design View: Here’s a look at the final output that will be displayed to you.


Employee list

when the user selects the name of the employee by hitting the bar button titled event then he will get the list of the employee and when he selects a particular employee then the image of that particular employee will be displayed in the detail view (the one which is blank). 


Selected Employee Image

You can change the title of the bar button from event to any name of your choice we shall discuss this as we continue with the tutorial.
 
Step 1: Open Xcode create a new project and this time select the SplitViewController template from the template section.




click next give your project an appropriate name and save your application. Now once this is done their will be two classes that will be added into your project by the xcode with the name RootViewController and the DetailViewController.

RootView and DetailView

RootViewController: This class is a subclass of the UITableViewController and will contain the list of the employees at run time. You can do all the manipulations that you usually do with the iPhone’s table view controller.

DetailViewController: This class is a subclass of the UIViewController and will contain an instance of the UIImageView class and the UILabel class in which you will see the image and the name of the employee selected from the RootViewController (table view)

Step 2: Select the RootViewController.h file and declare an object of the NSMutableArray class and initialize it in the RootViewController.m file

#import <UIKit/UIKit.h>

@class DetailViewController;

@interface RootViewController : UITableViewController {


NSMutableArray *_empName;

}

@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;

@end

The initialization part in the RootViewController.m file

- (void)viewDidLoad

{

[super viewDidLoad];

self.clearsSelectionOnViewWillAppear = NO;

self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);

_empName = [[NSMutableArray alloc]initWithObjects:@"Radix", @"Riki",@"Jigar",@"Prem",@"Shrikant",nil];  

} 
Now when you traverse inside this file (RootViewController.m) you will see some of the commonly used delegate and datasource methods of the UITableView class so please add in the code that you used to display a table with the iPhone (Refer this tutorial in case you need help). Once when this is done I would request you to directly run the application and when you do hit the event bar button present in the toolbar to get the view which looks something like this




Step 3: In the groups and file their will be a DetailView.xib file select that file and add the UIImageView instance and the UILabel instance into it, and create the corresponding  IBOutlets for the UILabel instances inside the DetailViewController.h file and connect it accordingly. Once this step is done then I would like you to add in some images inside the application bundle of your choice that you might want to see when you hit the table view.

After this step I want you to create a property of NSNumber class inside the DetailViewController.h file and synthesize it inside the DetailViewController.m file. Here’s a quick look at the code present in the DetailViewController.h file

#import <UIKit/UIKit.h>

@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate> {

     
    UIImageView *_empImageView;

    NSNumber *_theindexNumber;

    IBOutlet UILabel *empNameLabel;

}



@property (nonatomic,retain) NSNumber *_theindexNumber;

@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;

@property (nonatomic, retain) id detailItem;

@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel;

@end

Synthesize the NSNumber property inside the DetailViewController.m file

#import "DetailViewController.h"

#import "RootViewController.h"


@interface DetailViewController ()

@property (nonatomic, retain) UIPopoverController *popoverController;

- (void)configureView;

@end


@implementation DetailViewController


@synthesize toolbar=_toolbar;

@synthesize _theindexNumber;

@synthesize detailItem=_detailItem;

@synthesize detailDescriptionLabel=_detailDescriptionLabel;

@synthesize popoverController=_myPopoverController;



Step 4: All the settings that we did in step 3 will now make sense, we have to show the image of the employee who will be selected from the list into the image view present in the DetailViewController and we know that if any row of the table view is selected then in that case the 


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 

delegate method gets triggered so inside the RootViewController.m file locate the did select method and add this piece of code their

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

//passing the row index that is selected by the user

detailViewController._theindexNumber = [NSNumber numberWithInt:indexPath.row];

   

//passing the employee name selected by the user

detailViewController.detailItem = [_empName objectAtIndex:indexPath.row]; 
 

}

The code is pretty much explained here via comments.


Note: The DetailViewController is already added in the RootViewController class have a look at the .h file of the RootViewController via forward class declaration methodology.

Now the last part that needs to be done is making use of this data inside the DetailViewController class so here’s what needs to be done

Inside the DetailViewController.m file there is a function called as the configure view so just add this piece of code their

- (void)configureView

{

    // Update the user interface for the detail item.


    switch ([_theindexNumber intValue]) {

        case 0:

            empNameLabel.text = [self.detailItem description];

            _empImageView.image = [UIImage imageNamed:@"Radix.jpg"];

            break;


        case 1:

            empNameLabel.text = [self.detailItem description];

            _empImageView.image = [UIImage imageNamed:@"Riki.jpg"];

            break;

        case 2:

            empNameLabel.text = [self.detailItem description];

            _empImageView.image = [UIImage imageNamed:@"jigar.jpg"];

            break;


        case 3:

            empNameLabel.text = [self.detailItem description];

            _empImageView.image = [UIImage imageNamed:@"prem.jpg"];

            break;


        case 4:

            empNameLabel.text = [self.detailItem description];

            _empImageView.image = [UIImage imageNamed:@"Shri.jpg"];

            break;


    }


}




Code Explanation: In the above code I am using a switch case block to change the image of the image view by making the usage of the row that is selected inside the RootViewController and the name of the employee is getting displayed in the label that we added. The configure view is called inside the method

-   (void)setDetailItem:(id)newDetailItem

which gets called whenever there is a change in the value of the detail item variable, 

Step 5: Run this application to get the output just like the image given below.

Employee List

Employee name: Riki
  
Employee name: Prem

I hope that this tutorial has helped you in working with the iPad split view controller, if you are having any sort of query then do let me know via comment or you may contact me via mails, my mail ID is given in the facebook badge above until then Happy iCoding and have a great Day.