Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Monday, December 23, 2013

Apple iPhone Application Development - Initial Steps

Apple iPhone Application Development - Initial Steps

Today, Apple iPhone application development is in full swing and iPhone developers are in great demand. In order to develop iPhone apps, you should be a good Objective C developer. If you have good grip on C++, OOPS Concepts, I can guarantee you that you can learn Objective C easily and quickly and can start building your iPhone apps. There are a lot of iPhone apps development tutorials available on the internet and very good iPhone apps development community on the stackoverflow, so you will not feel alone if you stuck anywhere while iPhone app development. Today, companies are hiring a lot of iPhone app developers for building their iPhone apps. XCode is the full featured tool which eases your iPhone app development to a large extent. A lot of demos, sample codes, sample applications are available on the internet which can fulfil your basic iPhone app functionalities. So, I am just giving the initial steps which you should take while iPhone app development.

Step 1: Think of a good idea

Have a unique idea for an iphone app? So what makes an app stand out?  Why would anyone want to use your app?  Why would they pay money for it if you are going to charge?

Be sure to check that there aren’t other apps that do the same thing that you are proposing. Or if you want to create something better than an app that already exists, think about how your idea will be better.  Draw it out on paper or on the computer.

Step 2: Get A Mac

The iPhone is an Apple product and uses a variation of the Mac OS. Currently, the iPhone development tools are only available for Mac users. You can buy a Mac mini relatively cheaply if you don’t have a Mac at your disposal.

Step 3: Register As An Apple Developer

To work with the Mac tools, you will need to become an official Apple Developer. Registration is free so you simply have to give them your information and agree to their terms.  You only need to register once, and you are able to use the same username and password used for your iTunes account. Once you are an Apple Developer, you can develop iPhone apps for any of the Mac products.

Step 4:  Download The Software Development Kit For iPhone (SDK)

Once you are an official developer, you can download the SDK for iPhone.  The version you need depends on the OS you are currently running.  This download is HUGE because it comes with all sorts of documentation, sample codes, and all sorts of things you will be glad to have later on. It could take a few hours, so you might want to start the download, put in a good movie, and wait.

Step 5: Download XCode

If you don’t already have it, download XCode.  According to Apple, “Xcode is a complete, full-featured IDE built around a smooth workflow that integrates the editing of source code, with the build and compile steps, through to a graphical debugging experience – all without leaving the view of your source code.”  This is another huge download, so you might want to rent a second movie.

Step 6: Develop Your iPhone App With The Templates In The SDK

Once you have your app drawn out on paper or in Photoshop, you can start designing it with the templates provided in the SDK.  This is where that HUGE amount of download time will be a huge benefit.  You will have lots of templates to choose from, and there are a lot of great YouTube clip tutorials on how to use the templates effectively.

Step 7: Learn Objective-C For Cocoa

If you love programming languages, you will love Objective-C.  If you don’t know how to program, this is the part that can get pretty sticky, so you might want to find a programmer friend or hire someone.  It really does help to get a book, too, for reference.

Step 8: Program Your App In Objective-C

Once you at least understand the basics of Objective-C (or at least know how to find answers to programming questions), you are ready to program your app.  It helps to take screenshots as you go along so you can remember what you tried.  Some apps can take just a few hours to program while other Apps can take months. Only you know how much detail you want out there for its maiden voyage in the App Store!

Step 9: Test The App In The iPhone Simulator

The SDK comes with a lovely iPhone Simulator.  You will need to load up your app and do your own testing.  You should try to work out as many bugs as possible and think about all the ways someone might use your app.

Step 10: Host A Bake Sale

Remember when I told you in the fine print that you would have to raise some cash?  This is that moment.  Sadly, loading an app into iTunes costs a one time member fee of $99 (USD).  There is no way out of this fee, but you might earn it back in triplicate if your app is worthy!  Truly though, you DO get a lot for your $99. For one, you get access to some of the coolest people on this side of Pluto!

Step 11: Have Others Test Your App

Once you pay your fee, you will be able to have others in the app community test your app and help you work out final bugs.  This is a great community, and testing new stuff is lots of fun. If you are a newbie like me, you will be in awe of the kings and queens of geeky stardom. Depending on the nature and complexity of your app, this process can take some time.

Step 12: Submit Your App For Approval

After testing your app in the community and working out all the bumps, you can submit the app to iTunes for approval.  You will be able to upload it right from the community.  The process of approval can take some time, so be patient!

Step 13: Watch The Dough & Traffic Roll In!

If you created a paid app, just wait for the money to roll in to shore. If you created a free app, watch the traffic!

Sunday, December 1, 2013

iPhone Basic Interview Questions and Answers for Developers

iPhone Basic Interview Questions and Answers for Developers 

If you are preparing for iPhone technical interview, you must go through following iPhone interview questions and answers which are very basic for an iPhone developer and you should know all these basic iPhone concepts. Following iPhone interview questions and anwsers cover basic iPhone concepts like iPhone OS, SDK, Architecture, MVC design pattern, COCOA, COCOA Touch, Objective C, Shallow and Deep Copy in Objective C, difference between implementing a category and inheritance, Apple push notification service, When to use NSMutableArray and when to use NSArray, difference between frame and bounds, UIWindow object, Garbage collector in iPhone, nonatomic, @synthesize, delegate methods of MKMapView, types of parser and lot more...Lets have look on these iPhone basic interview questions and answers. 

1. What is iPhone OS? 

iPhone OS runs on iPhone and iPod touch devices. Hardware devices are managed by iPhone OS and provides the technologies needed for implementing native applications on the phone. The OS ships with several system applications such as Mail, Safari, Phone, which provide standard services to the user. 

2. What is iPhone SDK?

iPhone SDK is available with tools and interfaces needed for developing, installing and running custom native applications. Native applications are built using the iPhone OS’s system frameworks and Objective-C language and run directly on iPhone OS. Native applications are installed physically on a device and can run in presence or absence of network connection.

3. What is iPhone Architecture? 

It is similar to MacOS X architecture. It acts as an intermediary between the iPhone and iPod hardware an the appearing applications on the screen. The user created applications never interact directly with the appropriate drivers, which protects the user applications from changes to the hardware.

4. What is MVC ? MVC Architecture of iPhone App.

Here are the reasons why we should use the MVC (Model View Controller)design pattern.
    
1. MVC is resuable: When the problems occurs, there is no need to invent a new solution, we just have to follow the pattern and adopt it as necessary.
    
2. MVC is expressive: By using the MVC design pattern our application becomes more expressive.

1).  Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.

2). View: The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the consistency in its presentation when the model changes.

3). Controller:  Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In  GUIs, the views and the controllers often work very closely together.

5. What are the ways to store data localy on iPhone device?

We store data localy in device through:

1. Plist.
2. NSUserDefaults.
3. SQLite.
4. CoreData.

6. Difference between COCOA, COCOA touch and objective C?

Objective C is a dynamic programming language - a bit like C++ and a bit like Java.

Cocoa is the application framework for Mac OS X. Cocoa Touch is the application framework for iPhone and iPod Touch - very similar to Cocoa. 

Cocoa is commonly referred to as the combination of the Foundation and AppKit frameworks, while Cocoa Touch is the combination of the Foundation and UIKit frameworks. Cocoa and Cocoa Touch sit on top of other collections of frameworks to create the API stacks. The other layers are Media, Core Services and Core OS. The main difference between Cocoa and Cocoa touch is that the UI classes and APIs aren't the same as Mac OS X, so instead of NSTextField, you have UITextField. Many of the classes share the same functionality and can be ported quite easily by simply changing the class name, though most will require some more changes, but usually nothing too heavy. There are also some differences between the Foundation frameworks in Cocoa and Cocoa Touch, most commonly missing classes, eg, Cocoa has NSHost and Cocoa Touch doesn't.

7. Difference between shallow copy and deep copy?

Shallow copy is also known as address copy. In this process you only copy address not actual data while in deep copy you copy data. Suppose there are two objects A and B. A is pointing to a different array while B is pointing to different array. Now what I will do is following to do shallow copy.?Char *A = {‘a’,’b’,’c’};?Char *B = {‘x’,’y’,’z’};?B = A;?Now B is pointing is at same location where A pointer is pointing.Both A and B in this case sharing same data. if change is made both will get altered value of data.Advantage is that coping process is very fast and is independent of size of array.while in deep copy data is also copied. This process is slow but Both A and B have their own copies and changes made to any copy, other will copy will not be affected.

8. What is advantage of categories? What is difference between implementing a category and inheritance? 

You can add method to existing class even to that class whose source is not available to you. You can extend functionality of a class without subclassing. You can split implementation in multiple classes. While in Inheritance you subclass from parent class and extend its functionality.

9. Flow of push notification? 

Ans. Your web server sends message (device token + payload) to Apple push notification service (APNS) , then APNS routes this message to device whose device token specified in notification.

10. What is polymorphism?

This is very famous question and every interviewer asks this. Few people say polymorphism means multiple forms and they start giving example of draw function which is right to some extent but interviewer is looking for more detailed answer. Ability of base class pointer to call function from derived class at runtime is called polymorphism. For example, there is super class human and there are two subclasses software engineer and hardware engineer. Now super class human can hold reference to any of subclass because software engineer is kind of human. Suppose there is speak function in super class and every subclass has also speak function. So at runtime, super class reference is pointing to whatever subclass, speak function will be called of that class. I hope I am able to make you understand.

11. When to use NSMutableArray and when to use NSArray?

Ans. Normally we use mutable version of array where data in the array will change. For example, you are passing a array to function and that function will add some elements to that array or will remove some elements from array, then you will select NSMutableArray. When you don’t want to change you data, then you store it into NSArray. For example, the country names you will put into NSArray so that no one can accidentally modify it.

12. How is the app delegate is declared by Xcode project templates?

App delegate is declared as a subclass of UIResponder by Xcode project templates.

13. What is the purpose of UIWindow object?

The presentation of one or more views on a screen is coordinated by UIWindow object.

14. Whats the difference between frame and bounds?

The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

15. What is @interface?

It’s a keyword used to declare the Class.

16. What is @implementation?

It’s a keyword used to define the Class.

17. Garbage collector in iPhone?

iOS has got the ARC ( Automated reference counting ). Objective C does not have a garbage collector rather it uses the reference counting algorithm to manage the memory. This was the developers task until Apple launched iOS 5.0. Again if you are targeting iOS 4.0 or earlier , ARC is no more a choice for you.

18. What is delegate?

Delegate is an object that handles the events happening on an object. To do that delegate has to follow a protocol specifying the task it is going to handle.

19. What is @synthesize?

We use @synthesize to generate getters and setters automatically from compiler. We declare properties and then generate getter and setter method by using @synthesize.

20. What is nonatomic?

nonatomic and atomic are related to multithreading environment . If a property has an attribute as “nonatomic” that means multiple threads can modify that property concurrently. If the attribute is “atomic”, the threads would be given access atomically. So “Atomic” is thread safe while “nonatomic” is thread unsafe. Atomic drastically hampers the performance so until and unless not needed you should never go for atomic attribute. ‘nonatomic ’ will do in most of the cases.

21. What are the delegate methods of MKMapView?

Firstly you have added the storeKit framework in your xcode project then define the protocol as <MKMapviewDelegate> in .h file.

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
- (void)mapViewWillStartLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation;
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views;

22. What are the important delegate methods of NSXML parser?

-DidStartElement
-FoundCharecters
-DidEndElement
-FoundError

23. What is @dynamic and any place where it is used?

It tells compiler that getter and setter are not implemented by the class but by some other class.   
May be super class or child class.
Example – Core Data. 
- The Managed object classes have properties defined by using @dynamic.

24. Types of parsers?

There are various parsers available to parse an XML in iOS app development. You can choose either from iOS SDK provided by Apple or from third party libraries. Before discussing about various options, I want to highlight difference between XML parsers. Generally two types of parsers are used in XML parsing: SAX and DOM. Let's have a look at their brief description.

SAX parser- This parser is based on some notifying methods. These methods are notified as the SAX parser moves on the XML document. During the parsing activity, developer is responsible to construct required object and keep track of state of the XML parser. Some examples of this parser are as follows-

NSXMLParser - It is written in Objective-C and provided by Apple through its iOS SDK.

libxml2 - It is based on C language API and also provided by Apple through its iOS SDK. It supports both SAX and DOM parser.

DOM parser- This parser parse the complete document in a single go and converts it into a specific structured object. We can create XPath query for a particular element from this structured object. Some examples of this parser are as follows-

TBXML- It's a lightweight XML parser designed in such a way to consume very low memory. It's a good choice for an XML as well as that have the fixed structure.

TouchXML - It is another DOM parser. It is also read only but does not support XPath queries.

KissXML - It is based on TouchXML parser. It supports editing and writing XML unlike TouchXML parser.

TinyXML - It is very small DOM parser and based on C language API. It supports editing and writing XML documents like KissXML parser but does not support XPath queries.

GDataXML - It is developed by Google using Objective-C API. It supports both editing of XML documents and XPath queries.