My Blog List

Saturday 30 June 2012

How to solve "Oops, Yelp is overworked right now"


Hi folks,
This short post will help those who are planning to integrate Yelp in their mobile application for local business search ,getting review of customer about particular business  and much more.(for more hit www.yelp.com)
As the very first step of your yelp integration i.e. Signup  you will definitely  get above error if you are not  from the country list which yelp supports or may be if your IP address don't support  .
So to solve this problem i used proxy site (eg.http://ihide.info/).There are lots of free proxy site just google it.


I entered yelp signup url using above  proxy site and  that's it  No more Oops :-)








Thanks
for any query mail @ bpsingh216@gmail.com

Saturday 23 June 2012

HelloWorld iPhone Application

Hi folks,
Since it has been a long time that you people did not get any post from my side,This is very first post about iPhone app development .
I assume you people are familiar with basic of objective c and cocoa framework and Xcode.
So this post bring you the anatomy of first HelloWorld  application
let's start...

Prerequisites
1. Xcode
2.basic of  objective c and iphone SDK
last and foremost  patience :-)
Here are the following steps you need to build your HelloWorld application
1.Create new XCode Project
  Create your  project going through XCode ->File ->New Project and select  Empty Application .Name the project HelloWorld and click Save as shown in figure





XCode will create two file AppDelegate.h and AppDelegate.m . Difference between .h and .m file is in objective c all declaration goes to  .h file and implementation goes to .m file.
Now What  is AppDelegate  actually?
 When you create your  project, main.m file under  Supporting files is generated by XCode

it looks like

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
 as in any C program the execution of Objective -c application starts from main().the main() function starts by creating autorelease pool and ends by releasing it. In between it makes a call to the UiApplicationMain() function. UiApplicationMain() is declared as follows


int UIApplicationMain(int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName);


The UiApplicationMain() instantiate the application and the application delegate objects. after that,it sets the delegate property of the application object to the application delegate instance.


The Typical application delegate class looks like
#import <UIKit/UIKit.h>

@interface AppDelegate : NSObject <UIApplicationDelegate>
{
    
}
@end

Notice that application delegate class inherits NSObject class and adopts UIApplicationDelegate protocol and implements the UIApplicationDelegate methods.One of the very first  method of UiApplicationDelegate is 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{}

This method is starting point for developer didFinishLaunchinWithOptions is application life cycle method it is called when application will launch (onCreate() in Android )


 Note : NSObject is the super class of all classes available in objective c and Protocol is  here interface 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}



above code simply illustrate that when application will launch  a new window will be allocated by 

self.window = [[[UIWindow allocinitWithFrame:[[UIScreen mainScreenbounds]] autorelease];

and  set its background color to white by  

self.window.backgroundColor = [UIColor whiteColor];

at last make it visible.

2. Create User Interface using code 
 For your application very first object you need is appdelegate class which we have been seen above
now suppose you application has more than one screen so how will you create your screen(View)?
In iphone each screen is   ViewController (in Android Activity).
For this create a simple class which is a subclass of UIViewController going through
right click on AppDelegate.h  >>>newFile  >>Cocoa Touch >> UiViewController subclass >>next.
Name the file  and create it.





 3. Create object of your newly created UIViewController and add it to the main Window.


modify AppDelegate.h file with following piece of code

#import <UIKit/UIKit.h>
#import "HelloWorldViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    HelloWorldViewController *helloWorldVC;
}

@property (strong, nonatomic) UIWindow *window;

@end

modify AppDelegate.m file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // create viewcontroller object
    helloWorldVC=[[HelloWorldViewController alloc]init];
    
    
   //add it to the window
    [self.window addSubview:helloWorldVC.view];
    [self.window makeKeyAndVisible];
    return YES;
}

what you have done so far is you have created  HelloWorldViewController and added it to main window. now create label in your controller 

4.Create UiLabel and add it to HelloWorldViewController


  •  Open HelloWorldViewController.h file and declare UILabel

#import <UIKit/UIKit.h>

@interface HelloWorldViewController : UIViewController
{
    UILabel *label;
}

@end


  •  Open HelloWorldViewController.m file create label and set it's property

#import "HelloWorldViewController.h"

@implementation HelloWorldViewController

- (id)init
{
    self = [super init];
    if (self) {
        label=[[UILabel alloc]initWithFrame:CGRectMake(100, 250, 200, 30)];
        label.text=@"HelloWorld";
    }
    return self;
}

  •  Add label to ViewController
-(void)loadView
{
    [super loadView];
    [self.view addSubview:label];
}


5. Build and Run
Run your project by clicking run button (top left corner in XCode).





enjoy coding......
Feel free to comment .For any query mail me @ bpsingh216@gmail.com