Q1.What is the iPhone Application Entry point?
A. The main function:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MVC supports both loose and tight coupling, because there is usually a tight coupling
between the view and the controller because user actions are difficult to interpret without details of the presentation. For example:
Q12. What is the life cycle of view controller?
Q15. What is the way to store value as default in application without using nsuserdefault for the application run firts time, because first time there will be no any data in nsuserdefault.
A.
Through Plist.
Q16. What is the significant of passing (NSDictionary *)launchOptions in application didFinishLaunchingWithOptions ? What are the options in application didFinishLaunchingWithOptions ?
A.
Launching an application by tapping its icon, an application can be launched in order to respond to a specific type of event.
1. When application is not running, and user click on view button on the notification. To interpret this notification we have to implement application:didFinishLaunchingWithOptions: instead of applicationDidFinishLaunching: like this:
2. And when application is already in running state, in this case application delegate receives a call to application:didReceiveRemoteNotification:. This method also receives userInfo like this:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Q18. Difference between Cocoa and Cocoa touch ?
Q19. What is KVC and KVO ?
Q20. What architecture iOS follows ?
Q21. What are collection methods ?
Q22. How to handle NSLog before release ?
Now instead of
A. The main function:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
Q2.What is the GUI Entry Point?
A.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
Q3.What is the Model structure of iPhone Application?
A.
@interface RootViewController : UITableViewController {
NSArray *tableDataSource;
@interface RootViewController : UITableViewController {
NSArray *tableDataSource;
NSString *CurrentTitle;
NSInteger CurrentLevel;
IBOutlet UITableView * newsTable;
UIActivityIndicatorView * activityIndicator;
CGSize cellSize;
NSMutableArray * stories;
NSMutableDictionary * item;
NSString * currentElement;
NSMutableString * currentTitle, * currentDate, * currentSummary, * currentLink;
}
@property (nonatomic, retain) NSArray *tableDataSource;
@property (nonatomic, retain) NSString *CurrentTitle;
@property (nonatomic, readwrite) NSInteger CurrentLevel;
Q4.What is the View structure of iPhone Application?
A.
@interface loancalculatorViewController : UIViewController {
IBOutlet UITextField *tbxLoanAmount;
IBOutlet UITextField *annualInterestRate;
IBOutlet UITextField *noOfYears;
IBOutlet UILabel *monthlyPayment;
IBOutlet UILabel *totalInterest;
IBOutlet UILabel *totalPayment;
}
@property (nonatomic,retain) UITextField *tbxLoanAmount;
@property (nonatomic,retain) UITextField *annualInterestRate;
@property (nonatomic,retain) UITextField *noOfYears;
@property (nonatomic,retain) UILabel *monthlyPayment;
@property (nonatomic,retain) UILabel *totalInterest;
@property (nonatomic,retain) UILabel *totalPayment;
Q5.What is the Controller structure of iPhone Application?
A.
@interface RootViewController : UITableViewController {
mainView* myMainView;
}
- (id)init;
- (void)dealloc;
- (void)loadView;
Q6. What are Delegates in Objective-C?
Q6. What are Delegates in Objective-C?
A.
When we create an object of a class then some methods are automatically called, these methods are called delegates.
When we create an object of a class then some methods are automatically called, these methods are called delegates.
For example: when we create an object of UITableView like: UITableView *myTable;
then some methods like:
- numberOfSectionsInTableView:
- numberOfRowsInSection:
- heightForRowAtIndexPath:
- cellForRowAtIndexPath:
- didSelectRowAtIndexPath:
automatically called. These methods are called delegated.
Q7. What is the need of these Delegates?
A.
To execute some of must to do actions, we need these delegates.
To execute some of must to do actions, we need these delegates.
For example: for a table it is must decided that,
- How many row will be there.
- What will be the content on cell of each row.
- What will happen after selecting the row.
Q8. How Memory Management is handle in iphone?
A. click here.
Q9. What is MVC ?
A.
MVC (Model View Controller) is a design pattern used in services architectures. MVC separate the software architecture into three distinct elements. The 'Model' is how the underlying data is structured. The 'View' is what is presented to the user or consumer. The 'Controller' is the element that performs the processing. More.....
MVC (Model View Controller) is a design pattern used in services architectures. MVC separate the software architecture into three distinct elements. The 'Model' is how the underlying data is structured. The 'View' is what is presented to the user or consumer. The 'Controller' is the element that performs the processing. More.....
Q10. MVC supports loose or tight coupling?
A. MVC supports both loose and tight coupling, because there is usually a tight coupling
between the view and the controller because user actions are difficult to interpret without details of the presentation. For example:
• What object mouse clicked on
• What text area user typed into
Actions must be interpreted in terms of presentation
View has the information to map points in view to application objects
Refer the figure in this post.
• View needs to know about model. Controller needs to know about model and view, So view and the controller are tightly coupled.
• Model doesn’t need to know about either’s design, So Model loosely coupled to view/controller
Q11. What is atomic and nonatomic property attribute?
A.
Both are same unless we use our setter and getter methods.
If we create our own setter and getter method, then atomic is useful in thread processing, but it is slow.
Nonatomic does not give guarantee on thread processing but it is fast.
A.
- ViewDidLoad - The
viewDidLoadmethod is only called when the view is first loaded from the Nib file. If the view was already loaded and you push the view again it will not fire again. viewDidLoad is things you have to do once.Whenever I'm adding controls to a view that should appear together with the view, right away, I put it in the ViewDidLoad method. Basically this method is called whenever the view was loaded into memory. So for example, if my view is a form with 3 labels, I would add the labels here; the view will never exist without those forms. - ViewWillAppear: I use ViewWillAppear usually just to update the data on the form. So, for the example above, I would use this to actually load the data from my domain into the form. Creation of UIViews is fairly expensive, and you should avoid as much as possible doing that on the ViewWillAppear method, becuase when this gets called, it means that the iPhone is already ready to show the UIView to the user, and anything heavy you do here will impact performance in a very visible manner (like animations being delayed, etc).
when you are loading things from a server, you also have to think about latency. If you pack all of your network communication into viewDidLoad or viewWillAppear, they will be executed before the user gets to see the view - possibly resulting a short freeze of your app. It may be good idea to first show the user an unpopulated view with an activity indicator of some sort. When you are done with your networking, which may take a second or two (or may even fail - who knows?), you can populate the view with your data. Good examples on how this could be done can be seen in various twitter clients. For example, when you view the author detail page in Twitterrific, the view only says "Loading..." until the network queries have completed.
- ViewDidAppear: Finally, I use the ViewDidAppear to start off new threads to things that would take a long time to execute, like for example doing a webservice call to get extra data for the form above.The good thing is that because the view already exists and is being displayed to the user, you can show a nice "Waiting" message to the user while you get the data.
- ViewLoad: loadView is the method in UIViewController that will actually load up the view and assign it to the "view" property. This is also the location that a subclass of UIViewController would override if you wanted to programatically set up the "view" property.
I've found that often when I add init code to loadView, I end up with an infinite stack trace
Don't read self.view in -loadView. Only set it, don't get it.
The self.view property accessor calls -loadView if the view isn't currently loaded. There's your infinite recursion.
Q14. What are the ways to store data localy on device ?
A.
We store data localy in device through:
- Plist.
- NSUserDefaults.
- SQLite.
- CoreData.
Q15. What is the way to store value as default in application without using nsuserdefault for the application run firts time, because first time there will be no any data in nsuserdefault.
A.
Through Plist.
Q16. What is the significant of passing (NSDictionary *)launchOptions in application didFinishLaunchingWithOptions ? What are the options in application didFinishLaunchingWithOptions ?
A.
Launching an application by tapping its icon, an application can be launched in order to respond to a specific type of event.
For example, it could be launched in response to an incoming push notification, it could be asked to open a file, or it could be launched to handle some background event that it had requested. In all of these cases, the options dictionary passed to the
application:didFinishLaunchingWithOptions: method provides information about the reason for the launch.
In situations where the application is already running, the methods of the application delegate are called in response to key changes.
There are 7 launch options key:
UIApplicationLaunchOptionsURLKey;
UIApplicationLaunchOptionsSourceApplicationKey;
UIApplicationLaunchOptionsRemoteNotificationKey;
UIApplicationLaunchOptionsAnnotationKey;
UIApplicationLaunchOptionsLocalNotificationKey;
UIApplicationLaunchOptionsLocationKey;
UIApplicationLaunchOptionsNewsstandDownloadsKey;
For example:
When you actually receive a notification, there are 2 way it can be handel in our application:1. When application is not running, and user click on view button on the notification. To interpret this notification we have to implement application:didFinishLaunchingWithOptions: instead of applicationDidFinishLaunching: like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary* userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"];
NSDictionary *payLoad= [userInfo objectForKey:@"aps"];
NSDictionary *alertMsg = [userInfo objectForKey:@"alert"];
NSDictionary * badgeCount = [userInfo objectForKey:@"badge"];
//....do something with this.
}
2. And when application is already in running state, in this case application delegate receives a call to application:didReceiveRemoteNotification:. This method also receives userInfo like this:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSDictionary *payLoad= [userInfo objectForKey:@"aps"];
NSDictionary *alertMsg = [userInfo objectForKey:@"alert"];
NSDictionary * badgeCount = [userInfo objectForKey:@"badge"];
//....do something with this.
}
Q17. What are the design patterns in iOS ?
A.
Q18. Difference between Cocoa and Cocoa touch ?
A.
Q19. What is KVC and KVO ?
A.
Its a design pattern follow by iOS. Its a.......Q20. What architecture iOS follows ?
A.
Q21. What are collection methods ?
A.
For objects that manage a collection of objects (each called an element of that collection).
For example:
- (void)addElement:(elementType)anObj; - (void)removeElement:(elementType)anObj; - (NSArray *)elements;Q22. How to handle NSLog before release ?
A.
go into your Build settings and under the Debug configuration add a value to "Preprocessor Macros" value like: DEBUG_MODE=1
Make sure you only do this for the Debug configuration and not for Beta or Release versions. Then in a common header file you can do something like:
Make sure you only do this for the Debug configuration and not for Beta or Release versions. Then in a common header file you can do something like:
#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DLog( s, ... ) NSLog( @"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... )
#endif
Now instead of
NSLog use DLog everywhere. When testing and debugging, you'll get debug messages. When you're ready to release a beta or final release, all those DLog lines automatically become empty and nothing gets emitted. This way there's no manual setting of variables or commenting of NSLogs required. Picking your build target takes care of it.
ThankQ
Praveen

No comments:
Post a Comment