Translate

Monday, April 22, 2013

Objective C/iPhone/iPad/iOS Interview Questions


1. What is delegate? 

2. What is protocol? Types off protocols? By default Which type ?
3. What is the difference between Delegate and Protocol? 
4. What are categories?
5 . Difference b/w categories and Extend?
6. Difference b/w categories and Inheritance?
7. Is there over loading function in object c?
8.How objective C supports overloading and overriding ?
 9. How OOPS Concept supports to ObjectiveC?
 10.What is MVC? How It’s supported to objectiveC?
 11.Explain the Application LifeCycle?
 12.What is Protocol? Types of Protocols?
 13. Is Synthesis required? What is the Importance of it?
 14 How  should you manage memory?
 15. Delegate Methods?
 16.What are the controls?
 17.what is xib?
 18.Waht is the difference b/w loadview and viewdid load?
 19. How to change one controller to other controller?
 20. How to change the Default controller?
 21. How to Provide Multiple options to the user?
 22.What are required delegates for Table View?
 23. Table View Delegate Methods?
 24. How the memory allocated for table view?
 25.what are UI Text field methods?
 26. Difference b/w simulator and Device?
 27. Differences b/w IPAD And Iphone?
 28. Features of 4.0version?
 29. Difference B/w versions?
 30. How you Customize the table view?
 31. Difference B/w C,C++,ObjectiveC?
 32. What is Garbage Collection How it’s supported?
 33. Difference b/w Copy and Retain?
 34. Differences b/w Copy and Mutable Copy?
 35. Difference b/w Release  and Auto Release?
 36. What is the base class for all the classes?
 37. What are Data Types? What is the Default Data type?
 38. What are Access Specifiers? What is the Default Access Specifier?
 39. Differences b/w  String and NSString?
 40. Array allocation is Contiguous ?
 41. Differences b/w NSArray and NSMutable Array?
 42. What are the Design Patterns?
  Design Patterns :
  1. MVC
  2. Singleton :
A system only needs to create one instance of a class, and that instance will be accessed throughout the program. Examples would include objects needed for logging, communication, database access, etc. You could pass such an instance from method to method, or assign it to each object in the system. However, this adds a lot of unnecessary complexity.

  1. Factory design pattern :
The factory method pattern is an object-oriented design pattern to implement the concept of factories. Factory method Pattern is to "Define an interface for creating an object, but let the subclasses decide which class to instantiate.

43. What is singleton object? How it’s supported?

44.   Instance method followed by………………………
                Member variable
45.  Instance method begins with?
      -
46. Class method begins with?
     +
47. @interface
                Methods define
48. @implementation
                Define methods are implemented
49. Default constructor syntax is?
                - (id) init.

50. What is the difference b/w dismissmodelview control and presentviewmodel controller?

51.  Which API’s are using in u r application?
      API means frameworks like UIkit, foundation, Core animation

52. What is the cocoa?
     Object c framework called COCOA. The specific part of the framework used for iPhone app development is called Cocoa Touch

53 .What is the difference Between APPKit and UIKit?
   there is NO APPKit in iphone and there is no UIKit in Mac OS

54. What is diff between Get and Post methods?
55. What is NSPredicate?
56. which class is used for sorting the objects in array?
57. How to customize u r app in iphone?
Winterboard is an application that let you customize your iPhone / iPod 2.0+.
58. What is the Winterboard?
Winterboard allows you to customize Springboard of your iphone. Using Winterboard you can change iPhone icons, customize applications, status bar graphics, iPhone dock graphics, install themes and change wallpapers of your iPhone Springboard. You can even customize sounds on your iPhone. With Winterboard you can theme almost everything that comes to your mind. Before iPhone 2.0 there was Summerboard but Winterboard has replaced it since iPhone 2.0 and can even load themes of Summerboard.
59. What is the springboard?
Springboard is the standard application that manages the iOS (formerly iPhone OS) home screen.
60. Is it support multiple inheritance? How it’s over come?
Not supported                                                                                                     
61. What is the memory management?
                It allocates and reallocates memory and find out memory leaks.
62. What is the ton?
                Singletons are a class that only gets instantiated once in your application’s run-time.
63. How many layers are there in iphone sdk?
                .cocoa touch layer
                                Address book UI
                                UIkit
                .media layer
                                .audio toolbox
                                .audio unit
                                .AV foundation
                                .core Audio
                                .core graphics
                                .media player
                                .open GL ES
                                .quartz Core
                .core service layer
                                .address book
                                .core foundation  
                                .core location       
                                .foundation          
                                .system Configuration
                .core os layer
                                .CF network          
                                .security
                                .system
64. What is Parsing? Types of Parsing? Differences b/w types?
65. How File Handling should be done?
66. Permanent Storage?
67. What is APP Delegate? Why It’s used?
68. How handling the Data Base? Which Database your used?
69. Differences b/w SQLite and CoreData?
70. How Mapkit is used?
71. How change the Application Name?
72. What are the Frameworks you are used?
73. Essences of Library File?
74. What is Web Service? How it’s connected?
75. What it is NSURL?
76. Difference b/w SAX Parsing and DOM Parsing?
77. How to Implement Check Boxes and List View and Tree View and Combo box?
78.  What is Notifications? Types of Notifications?
79.  What is Push Notification?
80. How to handle device orientation?
         ShouldAutoRotatetointerfaceorientation – method
81. Deployment steps?
Deplolyment :
1)       Open applicatons- uitilites-keychain access –certificate assistance – requested a certificate from  a certifate authority
Email :
Savetodisk(radio button)
Ok
Certificate icon Is created in desktop. (developer certificate is created)
2)       Upload the developer certificate into developer.apple.com
Registed login :
3)       Create the provisioning profile from developer.applie.com and download it to system.

4)       Open the XCode and select the window -> organizer -> select the device and under provisioning profile tab drag it to device.

82. Steps for App Store Submission? 
83. What is IPA?
84. Adhoc distributions?
85. what is plist?
86. what is Multithreading? How it’s supported?
87.what is the dimensions of IPHone And IPAd?
88.What is the dismismodal view controller and present modal view controller?
89. Difference b/w Non Automic and Automic ?
90. Difference b/w Nib and Xib?
91. Difference b/w Data Source and Delegate?
92.what is Selector?
93.Difference b/w Array and NSDictionary?
94.Difference b/w Super and Base?
95. What are Application Life Cycle Phases?
96.How to build  the Application?
97.How to handle Errors and Bugs and Exceptions?
98. How to test the Application?
99. How to create the Custom controls?
100. How to Change the Color  for title bar of navigation bar?
101. Difference b/w Navigation And  Tab Bar controller?
102. What is JSON?
103. What is Gestures?
104. Difference b/w #define and #paragama and  #import?

Tuesday, April 9, 2013

iCloud implementation iOS5

STEP BY STEP METHOD TO IMPLEMENT ICLOUD 
Make sure your device is running iOS 5.

Turn on iCloud.
When you turn on a new iOS device or after you’ve completed the update to iOS 5, follow the onscreen instructions to activate your device and set up iCloud.
If you skipped the setup process or want to change your iCloud settings, tap the Settings icon on the Home screen and select iCloud.
Customize your settings.
Tap the Settings icon and select iCloud. Tap the On/Off switches to enable individual iCloud services, including Photo Stream, Documents, Find My iPhone, and more.
To enable Backup, tap Storage & Backup, then switch on iCloud Backup.
Now go to the Provisioning Portal to enable iCloud storage for your iOSapplication. Enabling this feature requires that you have an updated provisioning profile on your development systems.Xcode 4 handles this step for you automatically.
Add a new Entitlements file to your application and use it to configure the iCloud features for your application uses. Set the keys and values like this:
 
 
 
           •Now we have to do Entitlements  settings. Go to your target and select Summary tab and do the settings so           that it will look like this:
 
 
 
           •Now we have to do some setup for bundle settings. For this add a new setting bundle file under
           •Resource option in your project , it will have extension .bundle. Now this file contain a Root.plist file.
           •In Root.plist you will get 2 key, one is Preference Items with 4 items and another is Strings Filename. Delete all the items under Preference Items and setup it like this:
 
 
Now come on code, Go to your appDelegate.m file and write these line indidFinishLaunchingWithOptions method :
 
   [[NSUserDefaults standardUserDefaults] setValue:@"YES"   forKey:@"enableiCloud"];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSURL *iCloudURL = [fileManager                  URLForUbiquityContainerIdentifier:@"LCRABX9EHK.com.sapnasolutions.iCloudTest"];
    BOOL check = [fileManager isUbiquitousItemAtURL:iCloudURL];
    NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore   defaultStore];
    [cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"];
    [cloudStore synchronize]; // Important as it stores the values you set before on iCloud

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"saved.png"];
    BOOL existFile = [fileManager fileExistsAtPath:writableDBPath];
    // If the file exist then send it on iCloud.
    if (existFile) {
        NSError *errorOut=nil;
        BOOL success =[fileManager setUbiquitous:YES itemAtURL:[NSURL   URLWithString:writableDBPath]  destinationURL:iCloudURL error: &errorOut];
        NSLog(@"Error: %@", errorOut);
    }

query = [[NSMetadataQuery alloc] init];
        
        [query setSearchScopes:[NSArray   arrayWithObjects:NSMetadataQueryUbiquitousDataScopeNSMetadataQueryUbiquitousDocumentsScope, nil]];
        
        [query setPredicate:[NSPredicate predicateWithFormat:@"kMDItemFSName LIKE '*.png'"]];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryHandler:)name:NSMetadataQueryDidFinishGatheringNotification object:query];
        
        [query startQuery];
 
- (void)queryHandler: (NSNotification *) inNotification{
    NSLog(@"The number of results: %i", (int)[query resultCount]);
} 

Tuesday, April 2, 2013

iOS 6 SDK: Displaying App Store Products In-App


Have you ever had the need to send a customer from your iOS application to the App Store? Maybe you wanted her to rate your application in the App Store or you just wanted to promote one of your other apps. Prior to iOS 6, the only viable option was to send the customer to the App Store application. In iOS 6, however, Apple introduced the SKStoreProductViewController class, which allows an application to show a product in the App Store without leaving the application. In this quick tip, I will show you how this works.

Store Kit

As its class prefix indicates, the SKStoreProductViewController class is a member of the Store Kitframework. Using SKStoreProductViewController is incredibly easy. Before we take a look at an example application, it is useful to understand how everything fits together.
The SKStoreProductViewController class is a subclass of UIViewController, which means that it is easy to use if you are familiar with view controllers. Whenever you want to show a customer a product in the App Store, you (1) instantiate an instance of the SKStoreProductViewController class, (2) set its delegate, and (3) present the store product view controller to the customer. The operating system takes care of the rest. Keep in mind that an instance of the SKStoreProductViewController class can only be presented modally.
The SKStoreProductViewControllerDelegate delegate protocol defines a single method,productViewControllerDidFinish:. This method is called when the customer leaves the App Store, usually by tapping the cancel button in the top left of the view. By sending the delegate the message ofproductViewControllerDidFinish:, the operating system gives control back to your application. Let me show you how to use the SKStoreProductViewController class by creating a sample application.

Setting Up the Project

The application that we are about to build is not very functional as it only has one button, which takes the user to the App Store and shows the user Drizzle, a simple weather application that I released a few weeks ago. However, it shows you how the different pieces fit together and how to use theSKStoreProductViewController class in your projects.
Create a new project in Xcode by selecting the Single View Application template from the list of templates (figure 1). Name your application App Store, enter a company identifier, set iPhone for the device family, and check Use Automatic Reference Counting. The rest of the checkboxes can be left unchecked for this project (figure 2). Tell Xcode where you want to save the project and hit the Create button.
New in iOS 6: SKStoreProductViewController: Choosing a Project Template - Figure 1
New in iOS 6: SKStoreProductViewController: Configuring the New Project - Figure 2

 Adding the Store Kit Framework

Because the SKStoreProductViewController class is part of the Store Kit framework, we need to link our project against the Store Kit framework. Select the project in the Project Navigator and choose the target in the list of targets. At the top, choose the Build Phases tab and open the Link Binary With Libraries drawer. Click the button with the plus sign and choose StoreKit.framework form the list that appears (figure 3). You have now successfully linked your project against the Store Kit framework.
New in iOS 6: SKStoreProductViewController: Linking the Project Against the Store Kit Framework - Figure 3
To use the Store Kit framework in the MTViewController class, we need to import the framework’s header files. Open MTViewController.h and add the following import statement at the top.
1
#import <StoreKit/StoreKit.h>

Using theSKStoreProductViewControllerClass 

In the view controller’s viewDidLoad method, create a new button as shown in the snippet below. The button is of type UIButtonTypeRoundedRect and we position it at the center of the view controller’s view. We also give it a descriptive title and add a target-action pair to the UIControlEventTouchUpInsideevent. This means that whenever the user taps the button, the view controller receives a message ofopenAppStore:. This is the method where the magic happens.
1
2
3
4
5
6
7
8
9
10
11
- (void)viewDidLoad {
    [super viewDidLoad];
    // Initialize Button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setTitle:@"Go to App Store" forState:UIControlStateNormal];
    [button setFrame:CGRectMake(0.0, 0.0, 200.0, 44.0)];
    [button setCenter:self.view.center];
    [self.view addSubview:button];
    // Add Target-Action Pair
    [button addTarget:self action:@selector(openAppStore:) forControlEvents:UIControlEventTouchUpInside];
}
In the openAppStore: method, we initialize an instance of the SKStoreProductViewController class, set the delegate to self, and send it a message of loadProductWithParameters:completionBlock:. The loadProductWithParameters:completionBlock: accepts two arguments, (1) a dictionary with a key specifying the application identifier of the application that we want to show to the user and (2) a completion block. The completion block is executed when the request to the App Store is finished. In the completion block, we verify if no error was thrown and present the store product view controller to the user. Keep in mind that even though the user doesn’t leave your application, the operating system does connect to the App Store under the hood. It is also important to note that the request to the App Store can take a non-trivial amount of time. In other words, it is good practice to show an activity indicator to the user as long as the request has not returned a response. The completion block will allow us to dismiss the activity indicator once the request has finished, successfully or unsuccessfully.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
- (void)openAppStore:(id)sender {
    // Initialize Product View Controller
    SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
    // Configure View Controller
    [storeProductViewController setDelegate:self];
    [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"594467299"} completionBlock:^(BOOL result, NSError *error) {
        if (error) {
            NSLog(@"Error %@ with User Info %@.", error, [error userInfo]);
        } else {
            // Present Store Product View Controller
            [self presentViewController:storeProductViewController animated:YES completion:nil];
        }
    }];
}
You can find the unique identifier of an application in iTunes Connect. Every application in the App Store is given a unique identifier or Apple ID. Note that you need to pass the Apple ID in the parameters dictionary as a string.
Before building and running the application, we need to conform the MTViewController class to theSKStoreProductViewControllerDelegate protocol by implementing theproductViewControllerDidFinish: method. We start by updating the view controller’s interface file by telling the compiler that the MTViewController class conforms to theSKStoreProductViewControllerDelegate protocol (see below).
1
2
3
4
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>
@interface MTViewController : UIViewController <SKStoreProductViewControllerDelegate>
@end
In the view controller’s implementation file, implement the productViewControllerDidFinish: method as shown below. Remember that the store product view controller is presented modally when we invoke theloadProductWithParameters:completionBlock: method. It is our responsibility to dismiss the store product view controller when the customer decides to leave the App Store.
1
2
3
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
    [self dismissViewControllerAnimated:YES completion:nil];
}

Build and Run

Build and run the application to try it out. Even though Apple advertises theSKStoreProductViewController class as a way to show other apps to your users, it is also an ideal way to give users the chance to rate or review an app in the App Store without the hassle of leaving your application.
New in iOS 6: SKStoreProductViewController: The Store Product View Controller in Action - Figure 4


The SKStoreProductViewController class is a welcome addition to the Store Kit framework and I have already taken advantage of this new addition in some of my applications. I hope that I have convinced you of its usefulness with this quick tip.