Thursday 1 June 2017

Interview Questions for iOS

Q: Difference between atomic and Nonatomic
Object is read/ write safe but not thread safe (ATOMIC).Developer should ensure thread safety for such objects. All thread execute simultaneously producing any unpredictable result(non atomic).
Q: Difference between notifications and delegates
delegate is a one-to-one connection between the delegate and the delegating object.Notifications are posted application wide and can be observed by as many objects as needed creating a one-to-many connection. Delegation can be used to transfer information back from the delegate to the delegating object.Notifications however are a one way street. The information flows from the posting object to the observing objects.


Q: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.
Q:What is latest iOS version?
IOS 10.3
Q.What is latest Xcode version?
Xcode- 8.3.2
Q.What is latest mac os version?
 Mac- Sierra 10.12.5
Q.What is iPad screen size?
1024*768
Q.What are the features is IOS 6?
1.Map :beautifully designed from the ground up (and the sky down)
2.Integration of Facebook with iOS
3.shared photo streams.
4.Passbook - boarding passes, loyalty cards, retail coupons, cinema tickets and more all in one place
5.Facetime - on mobile network as wifi
6.changed Phone app - *remind me later,*reply with message.
7.Mail - redesigned more streamline interface.
8.Camera with panorama .
Q.Who invented Objective c?
Broad cox and Tom Love
Q.What is Cococa and cocoa touch?
Cocoa is for Mac App development  and cocoa touch is for apples touch devices - that provide all development environment
Q.What is Objective c?
*Objective-C is a reflective, object-oriented programming language which adds Smalltalk-style messaging to the C programming language. strictly superset of c.
Q. how declare methods in Objective c? and how to call them?
 - (return_type)methodName:(data_type)parameter_name : (data_type)parameter_name
Q. What is property in Objective c?
Property allow declared variables with specification like atomic/nonatmic, or retain/assign
Q.What is meaning of "copy" keyword?
copy object during assignment and increases retain count by 1
Q.What is meaning of "readOnly" keyword?
 Declare read only object / declare only getter method
Q.What is meaning of "retain" keyword?
Specifies that retain should be invoked on the object upon assignment. takes ownership of an object
Q.What is meaning of "assign" keyword?
Specifies that the setter uses simple assignment. Uses on attribute of scalar type like float,int.
16.What is meaning of "atomic" keyword?
"atomic", the synthesized setter/getter will ensure that a whole value is always returned from the getter or set by the setter, only single thread can access variable to get or set value at a time 
Q.What is meaning of "nonatomic" keyword?
In non atomic no such guaranty that value is returned from variable is same that setter sets. at same time

-fno -objc -arc

18.What is difference between "assign" and "retain" keyword?

Retain -Specifies that retain should be invoked on the object upon assignment. takes ownership of an object
Assign - Specifies that the setter uses simple assignment. Uses on attribute of scalar type like float,int.

19.What is meaning of "synthesize" keyword ?
ask the compiler to generate the setter and getter  methods according to the specification in the declaration
20.What is "Protocol" on objective c?
A protocol declares methods that can be implemented by any class. Protocols are not classes themselves. They simply define an interface that other objects are responsible for implementing. Protocols have many advantages. The idea is to provide a way for classes to share the same method and property declarations without inheriting them from a common ancestor
Q.What is use of UIApplication class?
The UIApplication class implements the required behavior of an application.
Q.What compilers apple using ?
The Apple compilers are based on the compilers of the GNU Compiler Collection.
Q.What is synchronized() block in objective c? what is the use of that?
The @synchronized()directive locks a section of code for use by a single thread. Other threads are blocked until the thread exits the protected code.
Q. What is the "interface" and "implementation"?
interface declares the behavior of class and implementation defines the behavior of class.

Q.What is "private", "Protected" and "Public" ?
private - limits the scope class variable to the class that declares it.
protected - Limits instance variable scope to declaring and inheriting classes.
public - Removes restrictions on the scope of instance variables

Q. What is the use of "dynamic" keyword?
Instructs the compiler not to generate a warning if it cannot find implementations of accessor methods associated with the properties whose names follow.
Q.What is "Delegate" ?
A delegate is an object that will respond to pre-chosen selectors (function calls) at some point in the future., need to implement the protocol method by the delegate object.
Q.What is "notification"?
provides a mechanism for broadcasting information within a program, using notification we can send message to other object by adding observer .

Q.What is difference between "protocol" and "delegate"?
protocol is used the declare a set of methods that a class that "adopts" (declares that it will use this protocol) will implement.
Delegates are a use of the language feature of protocols. The delegation design pattern is a way of designing your code to use protocols where necessary.

Q.What is "Push Notification"?
to get the any update /alert from server .

Q.How to deal with SQLite database?
Dealing with sqlite database in iOS:
1. Create database : sqlite3 AnimalDatabase.sql
2.Create table and insert data in to  table :
CREATE TABLE animals ( id INTEGER PRIMARY KEY, name VARCHAR(50), description TEXT, image VARCHAR(255) );

INSERT INTO animals (name, description, image) VALUES ('Elephant', 'The elephant is a very large animal that lives in Africa and Asia', 'http://dblog.com.au/wp-content/elephant.jpg');

3. Create new app --> Add SQLite framework and database file to project
4. Read the database and close it once work done with database :
// Setup the database object
    sqlite3 *database;

    // Init the animals Array
    animals = [[NSMutableArray alloc] init];

    // Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement = "select * from animals";
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            // Loop through the results and add them to the feeds array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
                // Read the data from the result row
                NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
                NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
                NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];

                // Create a new animal object with the data from the database
                Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl];

                // Add the animal object to the animals Array
                [animals addObject:animal];

                [animal release];
            }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);

    }
    sqlite3_close(database);


Q.What is storyboard?
With Storyboards, all screens are stored in a single file. This gives you a conceptual overview of the visual representation for the app and shows you how the screens are connected. Xcode provides a built-in editor to layout the Storyboards.
    1.    .storyboard is essentially one single file for all your screens in the app and it shows the flow of the screens. You can add segues/transitions between screens, this way. So, this minimizes the boilerplate  code required to manage multiple screens.
    2.      2.   Minimizes the overall no. of files in an app.

Q.What is Category in Objective c?
A category allows you to add methods to an existing class—even to one for which you do not have the source.
Q.What is block in objective c?
Blocks are a language-level feature added to C, Objective-C and C++, which allow you to create distinct segments of code that can be passed around to methods or functions as if they were values. Blocks are Objective-C objects, which means they can be added to collections like NSArray or NSDictionary. They also have the ability to capture values from the enclosing scope, making them similar to closures or lambdas in other programming languages.
Q. How to parse xml? explain in deep.

Using NSXMLParser.
Create xml parser object with xml data, set its delegate , and call the parse method with parserObject.
Delegate methods getting called :
– parserDidStartDocument:
– parserDidEndDocument:
– parser:didStartElement:namespaceURI:qualifiedName:attributes:
– parser:didEndElement:namespaceURI:qualifiedName:
– parser:didStartMappingPrefix:toURI:
– parser:didEndMappingPrefix:
– parser:resolveExternalEntityName:systemID:
– parser:parseErrorOccurred:
– parser:validationErrorOccurred:
– parser:foundCharacters:
– parser:foundIgnorableWhitespace:
– parser:foundProcessingInstructionWithTarget:data:
– parser:foundComment:
– parser:foundCDATA:

-fno

Q.How to parse JSON? explain in deep.
By using NSJSONSerialization.
For example : NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e];

Q.How to use reusable cell in UITableview?
By using dequeReusableCellWithIdentifier

Q.What is the meaning of "strong"keyword?
*strong -o "own" the object you are referencing with this property/variable. The compiler will take care that any object that you assign to this property will not be destroyed as long as you (or any other object) points     to it with a strong reference.
Q.What is the meaning of "weak" keyword?
*Weak - weak reference you signify that you don't want to have control over the object's lifetime. The object you are referencing weakly only lives on because at least one other object holds a strong reference to it. Once that is no longer the case, the object gets destroyed and your weak property will automatically get set to nil.
40.What is difference strong and  weak reference ? explain.
complier with be responsible for lifetime of object which is declared as strong. for weak object - compiler will destroy object once strong reference that hold weak object get destroyed.

Q.What is ARC ? How it works? explain in deep.
Automatic reference counting (ARC)  If the compiler can recognize where you should be retaining and releasing objects, and put the retain and release statement in code.

Q. What manual memory management ?  how it work?
In Manual memory management  developers is responsible for life cycle of object. developer has to retain /alloc and release the object wherever needed.

Q. How to find the memory leaks in MRC?
By using -
1.  Static analyzer.
2. Interface builder.
44.what is use of NSOperation? how NSOperationque works?
An operation object is a single-shot object—that is, it executes its task once and cannot be used to execute it again. You typically execute operations by adding them to an operation queueAn NSOperationQueue object is a queue that handles objects of the NSOperation class type. An NSOperation object, simply phrased, represents a single task, including both the data and the code related to the task. The NSOperationQueue handles and manages the execution of all the NSOperation objects (the tasks) that have been added to it.


Q.What is autorealease pool?
Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.
Autorelease pools are simply a convenience that allows you to defer sending -release until "later". That "later" can happen in several places, but the most common in Cocoa GUI apps is at the end of the current run loop cycle.


Q.Difference between nil and Nil.
Nil is meant for class pointers, and nil is meant for object pointers
Q.What is fast enumeration?
for(id object in objets){
}

Q. How to start a thread?
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg on NSObject
  NSThread* evtThread = [ [NSThread alloc] initWithTarget:self
                            selector:@selector( saySomething )
                          object:nil ];
    [ evtThread start ];

Q.How to download something from the internet?
By Using NSURLConnection , by starting connection or sending synchronous request.

Q.what is synchronous web request and asynchronous ?
In  synchronous request main thread gets block and control will not get back to user till that request gets execute.
In Asynchronous control gets back to user even if request is getting execute.

Q. Difference between sax parser and dom parser ?
SAX (Simple API for XML)
    1.    Parses node by node
    2.    Doesn't store the XML in memory
    3.    We can not insert or delete a node
    4.    Top to bottom traversing

DOM (Document Object Model)
    1.    Stores the entire XML document into memory before processing
    2.    Occupies more memory
    3.    We can insert or delete nodes
    4.    Traverse in any direction




Q.What are the ViewController  lifecycle in ios?
loadView - viewDidLoad-viewWillAppear-viewDidAppear - viewDisappear  - viewDidUnload

Q.Difference between coredata & sqlite?

There is a huge difference between these two. SQLLite is a database itself like we have MS SQL Server. But CoreData is an ORM (Object Relational Model) which creates a layer between the database and the UI. It speeds-up the process of interaction as we dont have to write queries, just work with the ORM and let ORM handles the backend. For save or retrieval of large data, I recommend to use Core Data because of its abilities to handle the less processing speed of IPhone.


Q.Steps for using coredata?
NSFetchedResultsController - It is designed primarily to function as a data source for a UITableView



Q.What are the Application lifecycle in ios?
ApplicationDidFinishLaunchingWithOption -ApplicationWillResignActive- ApplicationDidBecomeActive-ApplicationWillTerminate


Q.Difference between release and autorelease ?
release - destroy the object from memory,
autorelease - destroy the object from memory in future when it is not in use.

Q.How to start a selector on a background thread
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg on NSObject

Q.What happens if the methods doesn’t exist
App will crash with exception unrecognized selector sent to instance.

Q. How Push notification works?
Server - Apple server - device by using APNs

Delegate methods :
UITableView:
DataSource -
Configuring a Table View
– tableView:cellForRowAtIndexPath:  required method
– numberOfSectionsInTableView:
– tableView:numberOfRowsInSection:  required method
– sectionIndexTitlesForTableView:
– tableView:sectionForSectionIndexTitle:atIndex:
– tableView:titleForHeaderInSection:
– tableView:titleForFooterInSection:
Inserting or Deleting Table Rows
– tableView:commitEditingStyle:forRowAtIndexPath:
– tableView:canEditRowAtIndexPath:
Reordering Table Rows
– tableView:canMoveRowAtIndexPath:
– tableView:moveRowAtIndexPath:toIndexPath:

  Delegate -
Configuring Rows for the Table View
– tableView:heightForRowAtIndexPath:
– tableView:indentationLevelForRowAtIndexPath:
– tableView:willDisplayCell:forRowAtIndexPath:
Managing Accessory Views
– tableView:accessoryButtonTappedForRowWithIndexPath:
Managing Selections
– tableView:willSelectRowAtIndexPath:
– tableView:didSelectRowAtIndexPath:
– tableView:willDeselectRowAtIndexPath:
– tableView:didDeselectRowAtIndexPath:
Modifying the Header and Footer of Sections
– tableView:viewForHeaderInSection:
– tableView:viewForFooterInSection:
– tableView:heightForHeaderInSection:
– tableView:heightForFooterInSection:
Editing Table Rows
– tableView:willBeginEditingRowAtIndexPath:
– tableView:didEndEditingRowAtIndexPath:
– tableView:editingStyleForRowAtIndexPath:
– tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
– tableView:shouldIndentWhileEditingRowAtIndexPath:
Reordering Table Rows
– tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
Copying and Pasting Row Content
– tableView:shouldShowMenuForRowAtIndexPath:
– tableView:canPerformAction:forRowAtIndexPath:withSender:
– tableView:performAction:forRowAtIndexPath:withSender:

 UIPickerView-
 DataSource -
Providing Counts for the Picker View
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
  Delegate -
Setting the Dimensions of the Picker View
– pickerView:rowHeightForComponent:
– pickerView:widthForComponent:
Setting the Content of Component Rows
The methods in this group are marked @optional. However, to use a picker view, you must implement either thepickerView:titleForRow:forComponent: or the pickerView:viewForRow:forComponent:reusingView: method to provide the content of component rows.
– pickerView:titleForRow:forComponent:
– pickerView:viewForRow:forComponent:reusingView:
Responding to Row Selection
– pickerView:didSelectRow:inComponent:

UITextFeild-
Delegate -
Managing Editing
– textFieldShouldBeginEditing:
– textFieldDidBeginEditing:
– textFieldShouldEndEditing:
– textFieldDidEndEditing:
Editing the Text Field’s Text
– textField:shouldChangeCharactersInRange:replacementString:
– textFieldShouldClear:
– textFieldShouldReturn:

 UItextView-
 Delegate - Responding to Editing Notifications
– textViewShouldBeginEditing:
– textViewDidBeginEditing:
– textViewShouldEndEditing:
– textViewDidEndEditing:
Responding to Text Changes
– textView:shouldChangeTextInRange:replacementText:
– textViewDidChange:
Responding to Selection Changes
– textViewDidChangeSelection:

 MKMapView-
Delegate -
Responding to Map Position Changes
– mapView:regionWillChangeAnimated:
– mapView:regionDidChangeAnimated:
Loading the Map Data
– mapViewWillStartLoadingMap:
– mapViewDidFinishLoadingMap:
– mapViewDidFailLoadingMap:withError:
Tracking the User Location
– mapViewWillStartLocatingUser:
– mapViewDidStopLocatingUser:
– mapView:didUpdateUserLocation:
– mapView:didFailToLocateUserWithError:
– mapView:didChangeUserTrackingMode:animated:  required method
Managing Annotation Views
– mapView:viewForAnnotation:
– mapView:didAddAnnotationViews:
– mapView:annotationView:calloutAccessoryControlTapped:
Dragging an Annotation View
– mapView:annotationView:didChangeDragState:fromOldState:
Selecting Annotation Views
– mapView:didSelectAnnotationView:
– mapView:didDeselectAnnotationView:
Managing Overlay Views
– mapView:viewForOverlay:
– mapView:didAddOverlayViews:

NSURLConnection-
Delegate -
Connection Authentication

– connection:willSendRequestForAuthenticationChallenge:
– connection:canAuthenticateAgainstProtectionSpace:
– connection:didCancelAuthenticationChallenge:
– connection:didReceiveAuthenticationChallenge:
– connectionShouldUseCredentialStorage:
Connection Completion
– connection:didFailWithError:

NSURLConnectionDownloadDelegate
              – connection:didWriteData:totalBytesWritten:expectedTotalBytes:
– connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytes:
– connectionDidFinishDownloading:destinationURL:

 NSURLConnection
Preflighting a Request
+ canHandleRequest:
Loading Data Synchronously
+ sendSynchronousRequest:returningResponse:error:
Loading Data Asynchronously
+ connectionWithRequest:delegate:
– initWithRequest:delegate:
– initWithRequest:delegate:startImmediately:
+ sendAsynchronousRequest:queue:completionHandler:
– start
Stopping a Connection
– cancel
Scheduling Delegate Messages
– scheduleInRunLoop:forMode:
– setDelegateQueue:
– unscheduleFromRunLoop:forMode:

 NSXMLParser-
Handling XML
– parserDidStartDocument:
– parserDidEndDocument:
– parser:didStartElement:namespaceURI:qualifiedName:attributes:
– parser:didEndElement:namespaceURI:qualifiedName:
– parser:didStartMappingPrefix:toURI:
– parser:didEndMappingPrefix:
– parser:resolveExternalEntityName:systemID:
– parser:parseErrorOccurred:
– parser:validationErrorOccurred:
– parser:foundCharacters:
– parser:foundIgnorableWhitespace:
– parser:foundProcessingInstructionWithTarget:data:
– parser:foundComment:
– parser:foundCDATA:
Handling the DTD
– parser:foundAttributeDeclarationWithName:forElement:type:defaultValue:
– parser:foundElementDeclarationWithName:model:
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:
– parser:foundInternalEntityDeclarationWithName:value:
– parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:
– parser:foundNotationDeclarationWithName:publicID:systemID:


7.NSURLConnection
Connection Authentication
        – connection:willSendRequestForAuthenticationChallenge:
        – connection:canAuthenticateAgainstProtectionSpace:
        – connection:didCancelAuthenticationChallenge:
        – connection:didReceiveAuthenticationChallenge:
        – connectionShouldUseCredentialStorage:
Connection Completion
        – connection:didFailWithError:
MethodGroup
        – connection:needNewBodyStream
        – connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:  required method
        – connection:didReceiveData:  required method
        – connection:didReceiveResponse:  required method
        – connection:willCacheResponse:  required method
        – connection:willSendRequest:redirectResponse:  required method
        – connectionDidFinishLoading:  required method



Real Life Difference Between Encapsulation and Abstraction

Encapsulate means to hide. Encapsulation is also called data hiding.You can think Encapsulation like a capsule (medicine tablet) which hides medicine inside it. Encapsulation is wrapping, just hiding properties and methods. Encapsulation is used for hide the code and data in a single unit to protect the data from the outside the world. Class is the best example of encapsulation.

Abstraction refers to showing only the necessary details to the intended user. As the name suggests, abstraction is the "abstract form of anything". We use abstraction in programming languages to make abstract class. Abstract class represents abstract view of methods and properties of class.

Abstraction is "To represent the essential feature without representing the back ground details

What's the difference between overloading a method and overriding
Overloading a method is typically defined as "providing multiple available methods with the same name, differing by the number and type of inputs and outputs".
Overriding a method is typically defined as "providing a different implementation in a derived class of a method with a particular signature defined in the base class".
The overriding method has the same name, number and type of parameters, and return type as the method it overrides. An overriding method can also return a subtype of the type returned by the overridden method


Q:What are KVO and KVC?
KVC: Normally instance variables are accessed through properties or accessors but KVC gives another way to access variables in form of strings. In this way your class acts like a dictionary and your property name for example “age” becomes key and value that property holds becomes value for that key. For example, you have employee class with name property.
You access property like
NSString age = emp.age;
setting property value.
emp.age = @”20″;
Now how KVC works is like this
[emp valueForKey:@"age"];
[emp setValue:@"25" forKey:@"age"];
KVO : The mechanism through which objects are notified when there is change in any of property is called KVO.
For example, person object is interested in getting notification when accountBalance property is changed in BankAccount object.To achieve this, Person Object must register as an observer of the BankAccount’s accountBalance property by sending an
Key-Value Observing
Key-value observing is a mechanism that allows objects to be notified of changes to specified properties of other objects.

Q:Difference between nib and xib file
XIBs are flat files rather than being a bundle. This makes it easier for SCM systems to deal with. When you compile your app, the XIB is compiled into a NIB file for inclusion in your app. This means you can use XIBs and still compile for Tiger.
The compiled NIB that is included in the app bundle is no longer editable in Interface Builder and is much smaller than the equivalent XIB or legacy NIB file.
Difference between Frame and Bound
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
http://bitcode.in/blog/?p=88&goback=.nmp_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1#!
The difference between NSMutableString and NSString is that
NSMutableString: NSMutableString objects provide methods to modify the underlying array of characters they represent, while NSString does not. For example, NSMutableString exposes methods such as appendString, deleteCharactersInRange, insertString, replaceOccurencesWithString, etc. All these methods operate on the string as it exists in memory.
NSString: on the other hand only is a create-once-then-read-only string if you will; you'll find that all of its "manipulation" methods (substring, uppercaseString, etc) return other NSString objects and never actually modify the existing string in memory.



Q. Difference between deep copy and shallow copy
Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.
Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.



Q. What is NSCoder
The NSCoder abstract class declares the interface used by concrete subclasses to transfer objects and other Objective-C data items between memory and some other format. This capability provides the basis for archiving (where objects and data items are stored on disk) and distribution (where objects and data items are copied between different processes or threads). The concrete subclasses provided by Foundation for these purposes are NSArchiver, NSUnarchiver, NSKeyedArchiver, NSKeyedUnarchiver, and NSPortCoder. Concrete subclasses of NSCoder are referred to in general as coder classes, and instances of these classes as coder objects (or simply coders). A coder object that can only encode values is referred to as an encoder object, and one that can only decode values as a decoder object.
NSCoder operates on objects, scalars, C arrays, structures, and strings, and on pointers to these types. It does not handle types whose implementation varies across platforms, such as union, void *, function pointers, and long chains of pointers. A coder object stores object type information along with the data, so an object decoded from a stream of bytes is normally of the same class as the object that was originally encoded into the stream



Q.Differnace between new and alloc
Alloc : Class method of NSObject. Returns a new instance of the receiving class.
Init : Instance method of NSObject. Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.
New : Class method of NSObject. Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.

It depends on the Class, but [Class new] is most likely a convenience method that calls [[Class alloc] init] internally. Thus, you can not call other init methods such as "initWithString".
Some selected ones are:
    •    new doesn't support custom initializers (like initWithString)
    •    alloc-init is more explicit than new
General opinion seems to be that you should use whatever you're comfortable with.
Q. what is  NSJSON SERLIAZATION

Q. Difference between delegate and datasouce
Every collection view must have a data source object. The data source object is the content that your app displays. It could be an object from your app’s data model, or it could be the view controller that manages the collection view. The only requirement of the data source is that it must be able to provide information that the collection view needs, such as how many items there are and which views to use when displaying those items.
The delegate object is an optional (but recommended) object that manages aspects related to the presentation of and interaction with your content. Although the delegate’s main job is to manage cell highlighting and selection, it can be extended to provide additional information. For example, the flow layout extends the basic delegate behavior to customize layout metrics, such as the size of cells and the spacing between them.

Encapsulation is a strategy used as part of abstraction. Encapsulation refers to the state of objects - objects encapsulate their state and hide it from the outside; outside users of the class interact with it through its methods, but cannot access the classes state directly. So the classabstracts away the implementation details related to its state.
Abstraction is a more generic term, it can also be achieved by (amongst others) subclassing. For example, the interface List in the standard library is an abstraction for a sequence of items, indexed by their position, concrete examples of a List are an ArrayList or a LinkedList. Code that interacts with a List abstracts over the detail of which kind of a list it is using.
Abstraction is often not possible without hiding underlying state by encapsulation - if a class exposes its internal state, it can't change its inner workings, and thus cannot be abstracted.



#Xcode8 #iOS #Apple #Coding #iPhone#iPad #ObjectiveC #interview
© 2016 Girijesh
In case if any query/Concern send me a email @girijeshkumar2007@gmail.com






No comments: