Search This Blog

Monday, September 13, 2010

Interview Questions

1. How Do u know the Model or device name?

NSString *deviceType = [UIDevice currentDevice].model;
if( ![deviceType isEqualToString:@"iPhone"] )
{
}


2.How to know the String is there in the Array?

NSString *str = @"Hello";
NSArray *array = [[NSArray arrayWithObjects:@"",@"",@"",nil];
[array containsObject:str];


3. How to create a File/Directory?

XYZ
AppDelegate *appDelegate = (XYZAppDelegate *)[[UIApplication sharedApplication] delegate];
NSString *documentsPath = [appDelegate applicationDocumentsDirectory];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathOfFile = [documentsPath stringByAppendingPathComponent:@"VehiclePics"];
if(![fileManager fileExistsAtPath: pathOfFile])
[fileManager createDirectoryAtPath:vehiclePicsPath attributes:nil];

4.How to convert CGImage to UIImage?
UIImage *anImage = [UIImage imageWithCGImage:imageMasked];

//Converting UIImage to CGImage
CGImage *img = [anImage CGIMage];


5.How to call Delegate File Methods?
[(
XYZAppDelegate *)[[UIApplication sharedApplication] delegate] stopLoadingView];


6.How to compare Action sheet Strings?
if([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Take Photo"])


7.What is that initWithNibName?
A: This method allows initializing a UIViewController’s view from a nib file rather than from
code. You use this method when you want to write code that initializes a view controller
whose view resides in a nib. You should note that this is just one of several different ways
you might load a view from a nib into a class. By book’s end, you will be familiar with
most of them.


8. What is a delegate?
A: A delegate is a way to simplify the separation of processing logic from another class.
It also avoids inheritance. For instance, subclassing the UIApplication object would
be painful. Instead, Apple provides a UIApplicationDelegate. The UIApplication has
a reference to the class implementing the UIApplicationDelegate. If implemented,
the UIApplication delegates handling an event to the appropriate method in the
UIApplicationDelegate. It appears as if UIApplication is handling the event; in reality,
its delegate, UIApplicationDelegate, handles the event. Delegates are a common
object-oriented design pattern. For more information on delegates and object-oriented
programming, refer to the “delegation pattern” on Wikipedia (www.wikipedia.org).

9.How do u know Application Name? And OS version and OS NAme?
Ans.
NSString *applicationName = [[NSProcessInfo processInfo] processName];


10.How to set backGround View For Table Views?

cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ListBg.png"]] autorelease];
cell.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosure.png"]] autorelease];

No comments:

Post a Comment