Saturday, 26 December 2015

how to do sql lite connectivity with ios

hello friends.


(1) today i will tell how u doing simple sql lite connectivity with ios. first go to this link--->database files


(2)download this two file called DBoperatrion.h and DBoperation.m file now copy this file in your code


(3) now open dboperation file code and change database which u made
(4)open appdelegate.h file import dboperation.h

(5)ok now open appldelgate.m file and put this code in first method of app delegate
[dboperation checkcreatedb]


"check createdb is method of dboperation which we call"


ok now last if doing query for insert you use execute query and if you want to use data for select query than use select data method


THANK YOU FOR READING




Thursday, 23 July 2015

XML parsing basic Code

in viewcontroller.m file

NSURL *xmlURL=[NSURL URLWithString:@"http://www.espncricinfo.com/rss/content/story/feeds/0.xml"];
NSMutableURLRequest *xmlMainReq=[NSMutableURLRequest requestWithURL:xmlURL];
[xmlMainReq setHTTPMethod:@"GET"];
[xmlMainReq setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-Type"];
NSURLConnection *xmlConnection=[[NSURLConnection alloc]initWithRequest:xmlMainReq delegate:self];
if (xmlConnection)
{
xmlData=[[NSMutableData alloc]init];
}
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
//call at connection failed with any kind of reason...
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[xmlData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[xmlData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
xmlParse=[[NSXMLParser alloc]initWithData:xmlData];
xmlParse.delegate=self;
[xmlParse setShouldResolveExternalEntities:YES];
[xmlParse parse];
}




- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"item"])
{
channelDict=[[NSMutableDictionary alloc]init];
}
}

Wednesday, 17 June 2015

connect with database

https://drive.google.com/file/d/0B5LEuViUKd3_eGgyVUhJQ1RidjQ/view?usp=sharing

Monday, 15 June 2015

best interview ans for IOS

Answers:


1.What is latest iOS version?
IOS - 6.1.3 (updated on 5/15/13 3:15 AM Pacific Daylight Time)
2.What is latest Xcode version?
Xcode- 4.6.2 (updated on 5/15/13 3:15 AM Pacific Daylight Time)
3.What is latest mac os version?
Mac- Mountain Lion (updated on 5/15/13 3:15 AM Pacific Daylight Time)
4.What is iPad screen size?
1024X768
5.what is iPhone screen size?
320X480
6.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 .
7.Who invented Objective c?
Broad cox and Tom Love
8.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
9.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.
10. how declare methods in Objective c? and how to call them?
- (return_type)methodName:(data_type)parameter_name : (data_type)parameter_name
11. What is property in Objective c?
Property allow declared variables with specification like atomic/nonatmic, or retain/assign
12.What is meaning of "copy" keyword?
copy object during assignment and increases retain count by 1
13.What is meaning of "readOnly" keyword?
Declare read only object / declare only getter method
14.What is meaning of "retain" keyword?
Specifies that retain should be invoked on the object upon assignment. takes ownership of an object
15.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
17.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
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
21.What is use of UIApplication class?
The UIApplication class implements the required behavior of an application.
22.What compilers apple using ?
The Apple compilers are based on the compilers of the GNU Compiler Collection.
23.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.
24. What is the "interface" and "implementation"?
interface declares the behavior of class and implementation defines the behavior of class.
25.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
26. 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.
27.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.
28.What is "notification"?
provides a mechanism for broadcasting information within a program, using notification we can send message to other object by adding observer .
29.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.
30.What is "Push Notification"?
to get the any update /alert from server .

31.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); 32.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. .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. Minimizes the overall no. of files in an app. 33.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. 34.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. 35. 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:
36.How to parse JSON? explain in deep. By using NSJSONSerialization. For example : NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e]; √ 37.How to use reusable cell in UITableview?
By using dequeReusableCellWithIdentifier

38.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.
39.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.
41.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.
42. 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.
43. How to find the memory leaks in MRC? By using - 1. Static analyzer. 2. Instrument
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.
45.How to send crash report from device?
46.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.
47.What happens when we invoke a method on a nil pointer?
48.Difference between nil and Nil. Nil is meant for class pointers, and nil is meant for object pointers 49.What is fast enumeration? for(id object in objets){ }
50. 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 ];
51.How to download something from the internet? By Using NSURLConnection , by starting connection or sending synchronous request.
52.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.
53. Difference between sax parser and dom parser ? SAX (Simple API for XML) Parses node by node Doesn't store the XML in memory We can not insert or delete a node Top to bottom traversing
DOM (Document Object Model) Stores the entire XML document into memory before processing Occupies more memory We can insert or delete nodes Traverse in any direction
54.Explain stack and heap?
55.What are the ViewController lifecycle in ios? loadView - viewDidLoad-viewWillAppear-viewDidAppear - viewDisappear - viewDidUnload
56.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.
57.Steps for using coredata? NSFetchedResultsController - It is designed primarily to function as a data source for a UITableView
58.Procedure to push the app in AppStore?
59.What are the Application lifecycle in ios? ApplicationDidFinishLaunchingWithOption -ApplicationWillResignActive- ApplicationDidBecomeActive-ApplicationWillTerminate
60.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.
61.How to start a selector on a background thread - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg on NSObject 62.W
hat happens if the methods doesn’t exist App will crash with exception unrecognized selector sent to instance.
63. 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

importan interview que on ios

IMP IOS Questions

:

1.What is latest iOS version?
2.What is latest Xcode version?
3.What is latest mac os version?
4.What is iPad screen size?
5.what is iPhone screen size?
6.What are the features is IOS 6?
7.Who invented Objective c?
8.What is Cococa and cocoa touch?
9.What is Objective c?
10. how declare methods in Objective c? and how to call them?
11. What is property in Objective c?
12.What is meaning of "copy" keyword?
13.What is meaning of "readOnly" keyword?
14.What is meaning of "retain" keyword?
15.What is meaning of "assign" keyword?
16.What is meaning of "automic" keyword?
17.What is meaning of "nonautomic" keyword?
18.What is difference between "assign" and "retain" keyword?
19.What is meaning of "synthesize" keyword ?
20.What is "Protocol" on objective c?
21.What is use of UIApplication class?
22.What compilers apple using ?
23.What is synchronized() block in objective c? what is the use of that?
24. What is the "interface" and "implementation"?
25.What is "private", "Protected" and "Public" ?
26. What is the use of "dynamic" keyword?
27.What is "Delegate" ?
28.What is "notification"?
29.What is difference between "protocol" and "delegate"?
30.What is "Push Notification"?
31.How to deal with SQLite database?
32.What is storyboard?
33.What is Category in Objective c?
34.What is block in objective c?
35. How to parse xml? explain in deep.
36.How to parse JSON? explain in deep.
37.How to use reusable cell in UITableview?
38.What is the meaning of "strong"keyword?
39.What is the meaning of "weak" keyword?
40.What is difference strong and weak reference ? explain.
41.What is ARC ? How it works? explain in deep.
42. What manual memory management ? how it work?
43. How to find the memory leaks in MRC?
44.what is use of NSOperation? how NSOperationque works?
45.How to send crash report from device?
46.What is autorealease pool?
47.What happens when we invoke a method on a nil pointer?
48.Difference between nil and Nil.
49.What is fast enumeration?
50. How to start a thread? explain in deep.
51.How to download something from the internet?
52.what is synchronous web request and asynchronous ?
53. Difference between sax parser and dom parser ?
54.Explain stack and heap?
55.What are the ViewController lifecycle in ios?
56.Difference between coredata & sqlite?
57.Steps for using coredata?
58.Procedure to push the app in AppStore?
59.What are the Application lifecycle in ios?
60.Difference between release and autorelease ?
61.How to start a selector on a background thread
62.What happens if the methods doesn’t exist

Tuesday, 10 March 2015

Creating and Running Our First iOS App



Before we dive any deeper into the features of Objective-C, we should have a brief look at how to create a simple iOS app in Xcode. Xcode is Apple’s IDE (integrated develop‐ ment environment) that allows you to create, build, and run your apps on iOS Simulator and even on real iOS devices. We will talk more about Xcode and its features as we go along, but for now let’s focus on creating and running a simple iOS app. I assume that you’ve already downloaded Xcode into your computer from the Mac App Store. Once that step is taken care of, please follow these steps to create and run a simple iOS app: 1. Open Xcode if it’s not already open. 2. From the File menu, choose New Project... 3. In the New Project window that appears, on the lefthand side under the iOS cate‐ gory, choose Application and then on the right hand side choose Single View Application. Then press the Next button. 4. On the next screen, for the Product Name, enter a name that makes sense for you. For instance, you can set the name of your product as My First iOS App. In the
Organization Name section, enter your company’s name, or if you don’t have a company, enter anything else that makes sense to you. The organization name is quite an important piece of information that you can enter here, but for now, you don’t have to worry about it too much. For the Company Identifier field, enter com.mycompany. If you really do own a company or you are creating this app for a company that you work with, replace mycompany with the actual name of the com‐ pany in question. If you are just experimenting with development on your own, invent a name. For the Devices section, choose Universal. 5. Once you are done setting the aforementioned values, simply press the Next button. 6. You are now being asked by Xcode to save your project to a suitable place. Choose a suitable folder for your project and press the Create button. 7. As soon as your project is created, you are ready to build and run it. However, before you begin, make sure that you’ve unplugged all your iOS devices from your com‐ puter. The reason behind this is that once an iOS device is plugged in, by default, Xcode will attempt to build and run your project on the device, causing some issues with provisioning profiles (which we haven’t talked about yet). So unplug your iOS devices and then press the big Run button on the top-lefthand corner of Xcode. If you cannot find the Run button, go to the Product menu and select the Run menu item. Voilà! Your first iOS app is running in iOS Simulator now. Even though the app is not exactly impressive, simply displaying a white screen in the simulator, this is just the first step toward our bigger goal of mastering the iOS SDK, so hold on tight as we embark on this journey together.

Creating and Taking Advantage of Classes


A class is a data structure that can have methods, instance variables, and properties, along with many other features, but for now we are just going to talk about the basics. Every class has to follow these rules:
• The class has to be derived from a superclass, apart from a few exceptions such as NSObject and NSProxy classes, which are root classes. Root classes do not have a superclass. • It has to have a name that conforms to Cocoa’s naming convention for methods. • It has to have an interface file that defines the interface of the class. • It has to have an implementation where you implement the features that you have promised to deliver in the interface of the class. NSObject is the root class from which almost every other class is inherited. For this example, we are going to add a class, named Person, to the project we created in “Cre‐ ating and Running Our First iOS App” on page 2. We are going to then add two prop‐ erties to this class, named firstName and lastName, of type NSString. Follow these steps to create and add the Person class to your project: 1. In Xcode, while your project is open and in front of you, from the File menu, choose New → File... 2. On the lefthand side, ensure that under the iOS main section you have chosen the Cocoa Touch category. Once done, select the Objective-C Class item and press the Next button. 3. In the Class section, enter Person. 4. In the “Subclass of ” section, enter NSObject. 5. Once done, press the Next button, at which point Xcode will ask where you would like to save this file. Simply save the new class into the folder where you have placed your project and its files. This is the default selection. Then press the Create button, and you are done. You now have two files added to your project: Person.h and Person.m. The former is the interface and the latter is the implementation file for your Person class. In Objective- C, .h files are headers, where you define the interface of each class, and .m files are implementation files where you write the actual implementation of the class. Now let’s go into the header file of our Person class and define two properties for the class, of type NSString: @interface Person : NSObject @property (nonatomic, copy) NSString *firstName; @property (nonatomic, copy) NSString *lastName; @end Just like a variable, definition of properties has its own format, in this particular order:
1. The definition of the property has to start with the @property keyword. 2. You then need to specify the qualifiers of the property. nonatomic properties are not thread-safe. We will talk about thread safety in Chapter 16. You can also specify assign, copy, weak, strong, or unsafe_unretained as the property qualifiers. We will read more about these soon too. 3. You then have to specify the data type of the property, such as NSInteger or NSString. 4. Last but not least, you have to specify a name for the property. The name of the property has to follow the Apple guidelines. We said that properties can have various qualifiers. Here are the important qualifiers that you need to know about: strong Properties of this type will be retained by the runtime. These can only be instances of classes. In other words, you cannot retain a value into a property of type strong if the value is a primitive. You can retain objects, but not primitives. copy The same as strong, but when you assign to properties of this type, the runtime will make a copy of the object on the right side of the assignment. The object on the righthand side of the assignment must conform to the NSCopying or NSMutable Copying protocol. assign Objects or primitive values that are set as the value of a property of type assign will not be copied or retained by that property. For primitive properties, this qualifier will create a memory address where you can put the primitive data. For objects, properties of this type will simply point to the object on the righthand side of the equation. unsafe_unretained The same as the assign qualifier. weak The same as the assign qualifier with one big difference. In the case of objects, when the object that is assigned to a property of this type is released from memory, the runtime will automatically set the value of this property to nil. We now have a Person class with two properties: firstName and lastName. Let’s go back to our app delegate’s implementation (AppDelegate.m) file and instantiate an object of type Person:

#import "AppDelegate.h" #import "Person.h" @implementation AppDelegate - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ Person *person = [[Person alloc] init]; person.firstName = @"Steve"; person.lastName = @"Jobs"; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } We are allocating and initializing our instance of the Person class in this example. You may not know what that means yet, but continue to the “Adding Functionality to Classes with Methods”

Tuesday, 17 February 2015

Defining and Understanding Variables in ios

Defining and Understanding Variables All modern programming languages, including Objective-C, have the concept of vari‐ ables. Variables are simple aliases to locations in the memory. Every variable can have the following properties: 1. A data type, which is either a primitive, such as an integer, or an object 2. A name 3. A value You don’t always have to set a value for a variable, but you need to specify its type and its name. Here are a few data types that you will need to know about when writing any typical iOS app:

Mutable Versus Immutable If a data type is mutable, you can change if after it is initialized. For instance, you can change one of the values in a mutable array, or add or remove values. In contrast, you must provide the values to an im‐ mutable data type when you initialize it, and cannot add to them, remove them, or change them later. Immutable types are useful be‐ cause they are more efficient, and because they can prevent errors when the values are meant to stay the same throughout the life of the data.
NSInteger and NSUInteger Variables of this type can hold integral values such as 10, 20, etc. The NSInteger type allows negative values as well as positive ones, but the NSUInteger data type is the Unsigned type, hence the U in its name. Remember, the phrase unsigned in programming languages in the context of numbers always means that the number must not be negative. Only a signed data type can hold negative numbers.
CGFloat Holds floating point variables with decimal points, such as 1.31 or 2.40.
NSString Allows you to store strings of characters. We will see examples of this later.
NSNumber Allows you to store numbers as objects.
id Variables of type id can point to any object of any type. These are called untyped objects. Whenever you want to pass an object from one place to another but do not wish to specify its type for whatever reason, you can take advantage of this data type.
NSDictionary and NSMutableDictionary These are immutable and mutable variants of hash tables. A hash table allows you to store a key and to associate a value to that key, such as a key named phone_num that has the value 05552487700. Read the values by referring to the keys associated with them. NSArray and NSMutableArray Immutable and mutable arrays of objects. An array is an ordered collection of items. For instance, you may have 10 string objects that you want to store in memory. An array could be a good place for that. NSSet, NSMutableSet, NSOrderedSet, NSMutableOrderedSet Sets are like arrays in that they can hold series of objects, but they differ from arrays in that they contain only unique objects. Arrays can hold the same object multiple
times, but a set can contain only one instance of an object. I encourage you to learn the difference between arrays and sets and use them properly. NSData and NSMutableData Immutable and mutable containers for any data. These data types are perfect when you want to read the contents of a file, for instance, into memory. Some of the data types that we talked about are primitive, and some are classes. You’ll just have to memorize which is which. For instance, NSInteger is a primitive data type, but NSString is a class, so objects can be instantiated of it. Objective-C, like C and C++, has the concept of pointers. A pointer is a data type that stores the memory address where the real data is stored. You should know by now that pointers to classes are denoted using an asterisk sign: NSString *myString = @"Objective-C is great!"; Thus, when you want to assign a string to a variable of type NSString in Objective-C, you simply have to store the data into a pointer of type NSString *. However, if you are about to store a floating point value into a variable, you wouldn’t specify it as a pointer since the data type for that variable is not a class: /* Set the myFloat variable to PI */ CGFloat myFloat = M_PI; If you wanted to have a pointer to that floating point variable, you could do so as follows: /* Set the myFloat variable to PI */ CGFloat myFloat = M_PI; /* Create a pointer variable that points to the myFloat variable */ CGFloat *pointerFloat = &myFloat; Getting data from the original float is a simple dereference (myFloat), whereas getting the value of through the pointer requires the use of the asterisk (*pointerFloat). The pointer can be useful in some situations, such as when you call a function that sets the value of a floating-point argument and you want to retrieve the new value after the function returns. Going back to classes, we probably have to talk a bit more about classes before things get lost in translation, so let’s do that next.

http://vishal-sata.blogspot.com

Thursday, 12 February 2015

IOS VERSION CODE NAMES


While iOS doesn't enjoy public code-names like OS X - no Snow Leopard or Mountain Lion - they do use internal code names, typically derived from ski resorts. Here a list of previous, current, and future iOS code-names.
1.0: Alpine (1.0.0 - 1.0.2: Heavenly)
1.1: Little Bear (1.1.1: Snowbird, 1.1.2: Oktoberfest)
2.0: Big Bear
2.1: Sugarbowl
2.2: Timberline
3.0: Kirkwood
3.1: Northstar
3.2: Wildcat (iPad only)
4.0: Apex
4.1: Baker
4.2: Jasper (4.2.5 - 4.2.10: Phoenix)
4.3: Durango
5.0: Telluride
5.1: Hoodoo
6.0: Sundance
6.1: Brighton
7.0: Innsbruck
7.1: Sochi
8.0: Okemo
8.1: OkemoTaos
8.2: OkemoZurs
8.3:
8.4:
9.0:
We'll update as new versions are released or otherwise become known.

Wednesday, 11 February 2015

SMALL HISTORY OF IOS

In 2005, when Steve Jobs began planning the iPhone, he had a choice to either "shrink the Mac, which would be an epic feat of engineering, or enlarge the iPod". Jobs favored the former approach but pitted the Macintosh and iPod teams, led by Scott Forstall and Tony Fadell, respectively, against each other in an internal competition, with Forstall winning by creating the iPhone OS. The decision enabled the success of the iPhone as a platform for third-party developers: using a well-known desktop operating system as its basis allowed the many third-party Mac developers to write software for the iPhone with minimal retraining.Forstall was also responsible for creating a software developer's kit for programmers to build iPhone apps, as well as an App Store within iTunes.

The operating system was unveiled with the iPhone at the Macworld Conference & Expo, January 9, 2007, and released in June of that year. At first, Apple marketing literature did not specify a separate name for the operating system, stating simply what Steve Jobs claimed: "iPhone runs OS X" and runs "desktop applications"when in fact it runs a variant of [Mac] OS X, that doesn't run OS X software unless it has been ported to the incompatible operating system. Initially, third-party applications were not supported. Steve Jobs' reasoning was that developers could build web applications that "would behave like native apps on the iPhone".On October 17, 2007, Apple announced that a native Software Development Kit (SDK) was under development and that they planned to put it "in developers' hands in February". On March 6, 2008, Apple released the first beta, along with a new name for the operating system: "iPhone OS".

Apple had released the iPod Touch, which had most of the non-phone capabilities of the iPhone. Apple also sold more than one million iPhones during the 2007 holiday season. On January 27, 2010, Apple announced the iPad, featuring a larger screen than the iPhone and iPod Touch, and designed for web browsing, media consumption, and reading iBooks. In June 2010, Apple rebranded iPhone OS as "iOS". The trademark "IOS" had been used by Cisco for over a decade for its operating system, IOS, used on its routers. To avoid any potential lawsuit, Apple licensed the "IOS" trademark from Cisco.
By late 2011, iOS accounted for 60% of the market share for smartphones and tablet computers.[28] By the end of 2012, iOS accounted for 21% of the smartphone OS market and 43.6% of the tablet OS market.


WHAT IS IOS

iOS (previously iPhone OS) is a mobile operating system developed by Apple Inc. and distributed exclusively for Apple hardware. It is the operating system that powers many of the company's iDevices.
Originally unveiled in 2007 for the iPhone, it has been extended to support other Apple devices such as the iPod Touch (September 2007), iPad (January 2010), iPad Mini (November 2012) and second-generation Apple TV onward (September 2010). As of June 2014, Apple's App Store contained more than 1.2 million iOS applications, 500,000 of which were optimized for iPad. These apps have collectively been downloaded more than 60 billion times. It had a 21% share of the smartphone mobile operating system units shipped in the fourth quarter of 2012, behind Google's Android. By the middle of 2012, there were 410 million devices activated. According to the special media event held by Apple on September 12, 2012, 400 million devices had been sold by June 2012.
The user interface of iOS is based on the concept of direct manipulation, using multi-touch gestures. Interface control elements consist of sliders, switches, and buttons. Interaction with the OS includes gestures such as swipe, tap, pinch, and reverse pinch, all of which have specific definitions within the context of the iOS operating system and its multi-touch interface. Internal accelerometers are used by some applications to respond to shaking the device (one common result is the undo command) or rotating it in three dimensions (one common result is switching from portrait to landscape mode).
iOS shares with OS X some frameworks such as Core Foundation and Foundation; however, its UI toolkit is Cocoa Touch rather than OS X's Cocoa, so that it provides the UIKit framework rather than the AppKit framework. It is therefore not compatible with OS X for applications. Also while iOS also shares the Darwin foundation with OS X, Unix-like shell access is not available for users and restricted for apps, making iOS not fully Unix-compatible either.
Major versions of iOS are released annually. The current release, iOS 8.1.3, was released on January 27, 2015. In iOS, there are four abstraction layers: the Core OS layer, the Core Services layer, the Media layer, and the Cocoa Touch layer. The current version of the operating system (iOS 8.0), dedicates 1.3 - 1.5GB of the device's flash memory for the system partition, using roughly 800 MB of that partition (varying by model) for iOS itself. It runs on the iPhone 4S and later, iPad 2 and later, all models of the iPad Mini, and the 5th-generation iPod Touch.