Latest Entries »

2011 in review

The stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 22,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 8 sold-out performances for that many people to see it.

Click here to see the complete report.

1)Create new Project TestMkMapkit (Navigation based) in Xcode

Open the RootViewController.xib file in Interface Builder, remove default UITableView tool from xib file and add MapView in RootViewcontroller.xib.

2)Add Mapkit framework in project

In Groups and Files,right click on Framework, add->Existing frameworks->Select MapKit framework to access MKMapkit class and MKAnnotation class.

3)Set RootViewController.h file

Set .h Root file as UIViewController’s subclass and add MKMapViewDelegate in it, create IBOutlet object for a Mapkit

4)Used Interface Builder to connect UI control to code

and synthesize the mapView Object in .m class like
@synthesize mapView;

5)Build and run the program to see the successful access of google maps in iPhone using Mapkit framework

6)Create your separate MyAnnotation class to show multiple annotations on Map

Basically MyAnnotation class is a subclass of MkAnnotation having three major attributes-

CLLocationCoordinate2D- to set the latitude and longitude position
Title- to set the title of Annotation point
subTitle – we can set subtitle to MKAnnotationPoint



now import MyAnnotation.h file in RootViewController.m file, like this- #import “MyAnnotation.h” to create multiple Annotations.

7)If you want to access current location of user using CLLocation class

write following code in RootViewcontroller.m class

- (void)viewDidLoad {
    [super viewDidLoad];	
	CLLocation *userLoc = mapView.userLocation.location;
    CLLocationCoordinate2D userCoordinate = userLoc.coordinate;	
	NSLog(@"user latitude = %f",userCoordinate.latitude);
	NSLog(@"user longitude = %f",userCoordinate.longitude);	

8)Now create multiple annotations and add all annotation points in one mutable array.

Append this code at the end of viewDidLoad method,
NSMutableArray* annotations=[[NSMutableArray alloc] init];
	CLLocationCoordinate2D theCoordinate1;
    theCoordinate1.latitude = 37.786996;
    theCoordinate1.longitude = -122.419281;
	CLLocationCoordinate2D theCoordinate2;
    theCoordinate2.latitude = 37.810000;
    theCoordinate2.longitude = -122.477989;
	CLLocationCoordinate2D theCoordinate3;
    theCoordinate3.latitude = 37.760000;
    theCoordinate3.longitude = -122.447989;
	CLLocationCoordinate2D theCoordinate4;
    theCoordinate4.latitude = 37.80000;
    theCoordinate4.longitude = -122.407989;
	MyAnnotation* myAnnotation1=[[MyAnnotation alloc] init];
	myAnnotation1.subtitle=@"in the city";
	MyAnnotation* myAnnotation2=[[MyAnnotation alloc] init];
	myAnnotation2.subtitle=@"on a Bridge";
	MyAnnotation* myAnnotation3=[[MyAnnotation alloc] init];
	myAnnotation3.subtitle=@"in the forest";
	MyAnnotation* myAnnotation4=[[MyAnnotation alloc] init];
	myAnnotation4.subtitle=@"at Russian Hill";
	[mapView addAnnotation:myAnnotation1];
	[mapView addAnnotation:myAnnotation2];
	[mapView addAnnotation:myAnnotation3];
	[mapView addAnnotation:myAnnotation4];
	[annotations addObject:myAnnotation1];
	[annotations addObject:myAnnotation2];
	[annotations addObject:myAnnotation3];
	[annotations addObject:myAnnotation4];

        NSLog(@"%d",[annotations count]);

we added all the annotations on Map as well as in the mutable array, to Position the map so that all overlays and annotations are visible on screen,
by using annotations(MKMutableArray class) array, we gone integrate all the MK points(one by one) with the MKMapRect class, to concentrate the map with the all the MK points.

Append this code at the end of viewDidLoad method to concentratet the Map
// Walk the list of overlays and annotations and create a MKMapRect that
    // bounds all of them and store it into flyTo.
    MKMapRect flyTo = MKMapRectNull;
	for (id  annotation in annotations) {
		NSLog(@"fly to on");
        MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
        MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
        if (MKMapRectIsNull(flyTo)) {
            flyTo = pointRect;
        } else {
            flyTo = MKMapRectUnion(flyTo, pointRect);
    // Position the map so that all overlays and annotations are visible on screen.
    mapView.visibleMapRect = flyTo;

9)Now Once again Build and Run the project to see the all created Annotations on a Screen.

here is the image which shows all the points with respect to their latitude and longitude positions.

10)Last but not least. To set the MKAnnotation’s delegate method.

write the following code in RootViewcontroller.m class to play with the MKAnnotation’s delegate,

above code shows, how to animate MK points, how to change the color of MKAnnotation Points, how to set leftCalloutAccessoryView, rightCalloutAccessoryView of MKPinAnnotationView class.

11)Build and Run now to see the delegate method’s effects on MKPinAnnotations

that’s it from me, hopefully this will help to all iphone beginners!

code link-here

Ad Hoc build of iphone app is very important one as per the testing of an app is concerns on various device
You can send that build to client’s by using their UUID. Its very easy to get UUID of iPhone by plug-in iPhone and checked “Identifier” in Summary tab from iTune or Xcode Organiser.

Mandatory things!
1)Mac machine
2)Developer License($99)
3)Device for testing(Simulator is sufficient to generate Binary(Build))

After testing your code on simulator you need following things to run your application on Device(iPhone,iPad,iPod touch):

1)Create a certificate(developer/distribution) on iPhone developer portal(login to, Open Applications folder from your dock, open the Utilities folder and launch Keychain Access, In the Preferences menu, set Online Certificate Status Protocol (OSCP) and Certificate Revocation List (CRL) to “Off”.

Choose Keychain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.

In the below screen fill the information which you proviede while applying for iPhone developer program. So everything should be the same like you enter’s already.
So, In the User Email Address field, enter your email address. In the Common Name field enter your name. Empty CA (Certificate Authority) Email Address. Select the ‘Saved to Disk’ radio button and select ‘Let me specify key pair information’ and before clicking ‘Continue’ make sure that the all the fields entered matches the information that was submitted when you registered as an iPhone Developer.

Once you clicked on “Continue”, a prompt will be shown. Specify a file name and click ‘Save’. In the following screen select ‘2048 bits’ for the Key Size and ‘RSA’ for the Algorithm. Click ‘Continue’.

The Certificate Assistant will create a CSR file on your desktop.
After creating a CSR, log in to the iPhone Developer Program Portal and navigate to ‘Certificates’ > ‘Development’ and click ‘Add Certificate’.
Click the ‘Choose file’ button, select your CSR (from desktop) and click ‘Submit’. If the Key Size was not set to 2048 bits during the CSR creation process, the Portal will reject the CSR.
Upon submission the certificate, you have to clicked on Approve as well, if you are the Admin.
Once your CSR is approved by Admin then download that in to your mac machine. On your local machine, double-click the downloaded .cer file to launch Keychain Access and install your certificate. You will see the certificate with your Name there (either distribution or developer).
Note: After Certificate is created you will never have to do the this step again for any application. This is only one time process.

2)Creating an App Id is very easy and you dont have to do this step again while the process of developing any other application, you have to follow few simple steps:
Log in to the iPhone Developer Program Portal and navigate to ‘App IDs’ and click ‘Add Id’.
In “App Id Name” enter any name, in my case I will enter wildcard and in “App Id” enter something like * and clicked on Submit.

3)Now the second last step is to add devices on your Developer Portal.
Log in to the iPhone Developer Program Portal and navigate to ‘Devices’ and click ‘Add Device’.
In “Device Name” insert your Name/Client iPhone name(i.e AdeemApp) and in “Device ID (40 hex characters)” enter the 40 hex char words( these words can easily be found using iTunes. If you dont know then kindly mail me, I will guide you through). After that click on “Submit”

4)Now the last step is to create a Provisioning File for your iPhone or client’s iPhone and this will be your last step for creating binary which you can install on your iPhone or client’s.
In to the iPhone Developer Program Portal and navigate to ‘Provisioning’ > ‘Distribution’ and click ‘Add Profile’.
Now select “Ad Hoc” in “Distribution Method”
In “Profile Name” type your application name (i.e iphoneapp). This name will be your provisioning profile name.
In “App ID” select the app name (i.e wildcard) which you created in Step 2
Mark checked to all the Device ID’s you created in (Step 3) or you will need for distritbution.
Click Submit and after that refresh your page 1 or 2 times until you see the download button.
Download the Provisioning profile and copy it to your /YourUserName/Library/MobileDevice/Provisioning Profile folder.

5)Now everything is step up on Developer portal, open your project in Xcode

Select your project from “Group & File” in left side bar. Right click on it and select “Get Info”.

Move to “Configuration” tab and select “Release”. Press the “Duplicate” button from bottom, name is “Distribution”.

Click on “Build” tab and select “i-debug” and type in “Search in Build Settings” filed ‘Base SDK’ and select the current selected Device and change it to what device your application is targetting ( latest iOS 4.2)

Now in “Search in build setting” field type “code signing identity” and select the provisioning profile you created in Step 3. Also do the same thing for the child property “Any iPhone OS Device”.

Select your project from “Group & File” in left side bar. Right click on it and select “Add”> “New File”

Select “Code Signing” under “iPhone OS” and select “Entitlements” and clicked Next. Name it Entitlements.plist and press Finished

Now Close the Info screen and select the “Target” > “YourApp” from “Group & File” in left side bar and clicked on “Info” button again from Xcode.

Now looked for “Code Signing Entitlements” and double clicked on the empty place. It will come up with an prompt. Enter “Entitlements.plist” and press ok

Now in “Search in build setting” field type “code signing identity” and select the provisioning profile you created in Step 4. Also do the same thing for the child property “Any iPhone OS Device”.

Now Info screen is still open clicked on “Properties” tab and in Identifier field type the “* or com.yourorganization.appname”
Everything is set up, click on “Build”(cmd+B) from Xcode>Build
Now right click on “Product”>”YourApp” and select “Reveal in Finder”. This is your binary file so please zip this file.

6)Send this Zip file to your clients along with the provisioning file you created( in step 4). Asked them to drag that proviosiong file in to iTunese > Library> Applications and then drag that zip file in the same place. It will successfully be placed in iTunese Application. Installed it to your iPhone then using sync.

Google Maps For Android

1.Create a new Project “Google Maps”.

2.To make map library part of the standard library ,Open the ‘AndroidManifest.xml’ file and put following code inside the <application> element,

<uses-library android:name="" />

3.To take permission from Internet to retrieve a Google Map,in the manifest file put the following code inside the <manifest> element,

<uses-permission android:name="android.permission.INTERNET" />

4.Open the ‘main.xml’ file from res/layout , add the Map View as root node,

<?xml version="1.0" encoding="utf-8"?/>
< xmlns:android=""
android:apiKey="Your Maps API Key goes here"/>

5.To generate Maps API key, first create your private key(my-private-key.keystore),go to the Terminal and type following command,

$ keytool -genkey -v -keystore my-private-key.keystore -alias alias_name -keyalg RSA -validity 10000

follow the procedure for each pinged questions and remember the alias and password.

6.Generate MD5 Fingerprint- After generating my-private-key.keystore generate Fingerprint by using following command,

$ keytool -list -alias alias_name -keystore my-private-key.keystore

this command will generate MD5 fingerprint for e.g. like this-
Certificate fingerprint(MD5):94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98

7.Take that MD5 fingerprint and go to the url=>, you need to agree terms and conditions of android and paste your certificate’s MD5 fingerprint into the text-box and click on ‘Generate API Key’ Button.
your key will generate for e.g. like this-0M3kU2GKEeEbNi9kQxHJWKp3KLMDDfnEM5dv6uw

8.So use your Maps Api Key for project signing with your private key(my-private-key.keystore)-


View full article »