Reading version from info.plist file in iphone development

We can read our info plist file as Dictionary ,here is the code for reading version number for your application.

NSDictionary *infoPlist = [NSBundle mainBundle]infoDictionary];

we stored info.Plist file as dictionary value, now we read version number from that

NSString *VersionNum = [infoPlist objectForKey:@”CFBundleVersion”];

i hope that this might be useful, thanks in advance for your feedback and queries.

home Button and Lock Button Event Handling in iPhone development

when you are developing game or app in ios, you should handle these events ,users may press HOME button or LOCK button ,or your application may get interrupted during call ,SMS . Now i hope that you understand the reason why we should handle that ,for this problem apple has some delegate functions in app delegate
-applicationDidEnterBackground;
               this method invokes when application enters background(HOME button pressed).
 
-applicationDidBecomeActive;
              this method invokes when application become active and about to start running your app.
 
-applicationWillResignActive;
              this method invokes when application resigns active.
 
-applicationEnteredForeground;
             this method invokes when your app comes to foreground.
 
these methods are life cycle codes in iphone development.
expecting your feedback.Thank you

CoreLocation tutorial in iphone development

Implementing Built-in GPS in your app, it gives more advantage to you and users feel more comfortable with your apps, in ios development implementing this ,is very simple . Apple has powerful framework to do this,namely CoreLocation frameWork.But one thing is if you didnt properly use this methods,it would consume more power, so you have to do it properly,shutdown it as procedure,by doing this CoreLocation framework would consume less power, now we have look at this framework.

Since we’re going to be using Core Location with our iOS app, we need to add the header file (CoreLocation/CoreLocation.h) to our prefix header (usually with the extension .pch). In this prefix header, locate the #ifdef __OBJC__ line,

#ifdef __OBJC__

    #import

    #import

    #import  // added for Core Location

#endif

 

Next step is add CoreLocation framework in your project.by right click on frameworks->add existing framework->CoreLocation frameWork,

 

this framework has some important delegate methods,

 

We need to implement two important delegates in our class where we want to get messages ,

 

(void)locationManager🙁CLLocationManager *)manager didUpdateToLocation🙁CLLocation *)newLocation fromLocation🙁CLLocation *)oldLocation

 

this method will be called when new location messages recieved..

 

(void)locationManager🙁CLLocationManager *)manager didFailWithError🙁NSError *)error

 

This Delegate will be invoked if corelocation needs to report us failure messages,

 

Next we need to store the data where we currently located, for this add these two lines in @interface definition file.

 

@property (strong, nonatomic) CLLocationManager *locationManager;

@property (strong, nonatomic) CLLocation *currentLocation;

 

and add this line in @implementation file

 

@synthesize locationManager, currentLocation;

 

 

IMPLEMENTATION :

 

(void)locationManager🙁CLLocationManager *)manager didUpdateToLocation🙁CLLocation *)newLocation fromLocation🙁CLLocation *)oldLocation {

    self.currentLocation = newLocation;

 

    if(newLocation.horizontalAccuracy <= 100.0f) 

    {

         [locationManager stopUpdatingLocation]

    }

}

 

 

– (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {

    if(error.code == kCLErrorDenied) {

        [locationManager stopUpdatingLocation];

    } else if(error.code == kCLErrorLocationUnknown) {

        // retry

    } else {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@”Error retrieving location”

                              message:[error description]

                              delegate:nil

                              cancelButtonTitle:@”OK”

                              otherButtonTitles:nil];

        [alert show];

    }

}

 

REQUESTING UPDATES:

 

to setup corelocation you need to add these two line.

 

locationManager = [[CLLocationManager alloc] init];

locationManager.delegate = self;

[locationManager startUpdatingLocation];

 

Thats it,

I hope that this article might be useful, post your reviews and feedback below here to improve my skills.

best blogs ,sites and resources for iphone development

https://developer.apple.com/

              From this site, you can sign up for the developer program and download the necessary tools required to build iPhone apps. There is a developer fee of $99/annually in order to submit your newly built creations to have them appear on the app store, but you can download the tools and play around with them with a free account. 

http://iphonedevsdk.com/

                iPhone Dev SDK is a community for software developers interested in the iPhone SDK platform. Founded in March 2008, iPhone Dev SDK was one of the first communities for this revolutionary new platform.

What separates iPhone Dev SDK from the others is the friendly atmosphere the community provides for developers of all abilities. Whether you’ve been programming your entire life or are just now getting interested, you’ll find yourself welcomed to the community.

http://www.icodeblog.com/

               iCodeBlog.com features some of the best tutorials on the web, both on beginning and more advanced development concepts. It should get the novice beginner off to a good start as well as teach the established user a few things about parts of the API that they may have not explored yet. The blog is updated on a regular basis and would make a great addition to any iPhone developer’s bookmarks. 

https://www.adwhirl.com/

         Go through this site to earn more money with free apps with ad integration .

http://ideaswarm.com/

            useful one for tracking your application sales and graph .

getting ip address in iphone development

NSString*  ip=@“http://www.whatismyip.org/”;

NSURL *url = [[NSURL alloc] initWithString:ip];

NSString *ans = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];

NSLog(@“%@”,ans);

one more method

 

 

Import UIDevice-Reachability.h in your project then try with one of those commands:

NSString *myIp = [UIDevice localIPAddress];

NSString *myIp = [UIDevice localWiFiIPAddress];

NSString *myIp = [UIDevice whatismyipdotcom];

 

How to get country name and country code in iOS development

  NSLocale *locale = [NSLocale currentLocale];

    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

   

    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode

                                                                             value: countryCode]];

use this string for your use..

there is a drawback in this code ..this will not return string in english it returns that string in device language what user used in device,,, to get string alwys in english

use this code 

 

NSLocale *locale = [NSLocale currentLocale];

NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@“en_US”] autorelease];

NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode];

Binary Search

Binary Search in C Programming Following program explains binary Search:
Binary Search finds the position of a given value from an array .
Algorithm:
It starts with the middle element of the list.
1. If the middle element of the list is equal to the ‘input key’ then we have found the position the specified value.
2. Else if the ‘input key’ is greater than the middle element then the ‘input key’ has to be present in the last half of the list.
3. Or if the ‘input key’ is lesser than the middle element then the ‘input key’ has to be present in the first half of the list.

#include
int main(){
int a[10],i,n,m,c,l,u;
printf(“Enter the size of an array: “);
scanf(“%d”,&n);
printf(“Enter the elements of the array: ” );
for(i=0;i<n;i++){
scanf(“%d”,&a[i]);
}
printf(“Enter the number to be search: “);
scanf(“%d”,&m);
l=0,u=n-1;
c=binary(a,n,m,l,u);
if(c==0)
printf(“Number is not found.”);
else
printf(“Number is found.”);
return 0;
}
int binary(int a[],int n,int m,int l,int u){
int mid,c=0;
if(l<=u){
mid=(l+u)/2;
if(m==a[mid]){
c=1;
}
else if(m<a[mid]){
return binary(a,n,m,l,mid-1);
}
else
return binary(a,n,m,mid+1,u);
}
else
return c;
}

Bubble Sort

Bubble Sort in C Programming

#include
#include
int arr[20];
int n;
void get();
void BubbleSort();
void Show();

void main(){
clrscr();
printf(“- This Program Explains Sorting Using Bubble Sort Algorithm -\n\n”);
get();
BubbleSort();
Show();
getch();
}

void get(){
int i;
while(1){
printf(“Enter the size of the elements :\n”);
scanf(“%d”,&n);
if(n<=20)
break;
else
printf(“Sorry the maximum no of elements is 20\n\n”);
}
printf(“\n”);
printf(“———————-\n”);
printf(“Enter the values \n”);
printf(“———————-\n\n”);
for(i=0;i<n;i++)
scanf(“%d”,&arr[i]);
}

void BubbleSort(){
int i,j;
for(i=1;i<n;i++){

for(j=0;j<n-i;j++){

if(arr[j]>arr[j+1]){      //for descending use “<”

int t;
t=arr[j];
arr[j]=arr[j+1];
arr[j+1]=t;

}

}

}

}

void Show(){
int i;
printf(“\n”);
printf(“———————–\n”);
printf(“Sorted Array Elements\n”);
printf(“———————–\n”);
for(i=0;i<n;i++){
printf(“%d\n”,arr[i]);
}
}