Android Application Development details

Source: Internet
Author: User

During Apple's development, we will always see XCode, Interface Builder, and Object-c, which are so easy-to-use words. However, most people often think that XCODE is simple and InterfaceBuilder is like an operation,
However, Object-c is daunting. If we only want to learn it from beginners, we can understand its syntax, or you have understood the related concepts, such as JAVA, C #, or C, after developing C ++ and other languages, you will feel that any language,
It is necessary to be familiar with its syntax. Once you understand it, you will have mastered the language 60%. Well, OK. I hope this article will not make you feel tired.
1. How do we understand Xcode, OBJECT-C, and COCOA?
This is a simple question, but it is also a question that people can really understand. Most people cannot really clearly understand their understanding of something, so here I need to emphasize that if you
When you really start to study something, You need to really understand it and understand it. Here, we can simply think that XCode is actually an integrated development environment, compared with the commonly used NetBeans or Visual Studio, but Interface Builder, you can think of it as a display of its Interface,
However, Object is a development language, such as C, C ++, JAVA, and other independent languages. In the end, Cocoa is a lot of function libraries, if you use C #, you can think of it as an MFC.
2. What is OBJECT-C?
Here we want to focus on OBJECT-C, and from time to time the language of Mars, to be accurate, we can go to a good understanding of it, here I will describe it with its simple column, for example, we often see a large number of minus signs, brackets, and NS * in development,
First, the minus sign or the plus sign can indicate the beginning of a function, method, or message. For example, in C #, the method may be written as follows:
Public void helloWorld (int ){
// Xxx
}
However, using OBJECT-C is:
-(Void) helloWorld (INT) {
// Xxx
}
Here we need to note that there is no Private or Public description in Object-c, but some people think that you can regard it as public, however, when using the plus sign, you can directly call this function in this class for other functions without creating instances of this class, note that the plus sign is relatively static.
Next, let's talk about the brackets:
Brackets can usually be considered as how to call the method you write. In OBJECT_C, it can be considered as a message, such as in JAVA: this. demo (true), and in Object-C, it should be written as: [self demo: YES], OK ....
Again, let's talk about this very common NS *. Here, you can imagine that after Steve Jobs was squeezed out by Apple, he created a company called NextStep, here, let's take a look at NextStep. This library is excellent and won most researchers to study it. However, the current mac OS uses NextStep library for a long time.
NextStep:
NEXTSTEP. (There are many official languages, such as NextStep, NeXTstep, and NeXTSTEP, which are called NEXTSTEP at the beginning .) It is an operating system developed by NeXT. Inc. NeXT is also the late CEO of Apple Computer, a company founded after Steve Jobs left Apple Computer in 1985.
This system is based on Mach and BSD, uses Objective-C as the native language, and has advanced GUI interfaces. Version 1.0 was launched in September 18, 1989. At the beginning, NEXTSTEP was only executed on Motorola 68000 of NeXT computer. In 1992, NEXTSTEP 486 of PC was released. Version 3.1 and version 3.2 were launched in and respectively, but they failed. The final version of 3.3 was released in 1995, and the platform is not limited to the Motorola 68000 Family. It can also run on platforms such as ibm pc x86, Sun or the HP PA-RISC. Later, Apple purchased NeXT in February 1997 to become the basis of Mac OS X.
Features
• Advanced GUI.
• Similar to the MacOSX Dock, a running program will be allocated with an illustration. In fact, it should be said that MacOSX will continue the NeXTSTEP interface.
• The 48x48 full-color icon is the largest and most meticulous bit icon system at that time.
• Miller Columns file browsing interface. Files are displayed in a tree structure. Currently, Mac OS X's Finder adopts this concept.
• Use object-oriented programming. [Edit] version
Release Notes
0.8 may October 12, 1988
0.8a 1988
0.9 the first version was officially released in 1988, supporting only the NeXT hardware.
1.0 May 1989
1.0a November 1989
2.0 may September 18, 1990
2.1 may March 25, 1991
2.1a
2.2
3.0
3.1 support for iworkshop, PA-RISC, and iSCSI architectures began in May 25, 1993.
3.2 may October 1993
3.3 The last version released in the name of NeXTSTEP in February 1995 is also the most popular version.
The beta version 4.0 (beta version) is only available to developers.
After version 3.3, NeXT was bought by Apple.
[Edit] Application
• Tim berneas-li was the first WWW Server in the world to be launched on a NeXTCube Server. The first web browser (simply called WorldWideWeb) was developed using NeXTSTEP as the operating system.
• Excellent multimedia support, but only a few hospitals bought the NeXT computer to store the X-ray data. [Edit] others
There is an X11 Window Manager Window Maker that is imitating the NeXTSTEP interface.
Here we start with NS:
NSLog
NSString
NSInteger
NSURL
NSImage
.....
For example, NSLog (@ "% d", myInt)
The value of myint can be seen in the console control, that is, the dbg window can be opened when xcode is running. Of course, we are more accustomed to using MMessageBox for debugging.
For the above, you can also see other classes with names, such as CF, CA, CG, and UI:
For example:
CFStringTokenizer is used for word segmentation.
CALayer, which indicates the layer of Core Animation
CGPoint indicates a vertex.
UIImage indicates the image in the iPhone.
Break down the abbreviations:
CF refers to Core Foundation, CA refers to Core Animation, CG refers to Core Graphics, and UI refers to Iphone UUser Interface .......
Next, let's take a look at # import, @ interface,
Of course, for example, # import, you can think of it as # include. In what environment is used, you have to understand it in IPHONE development.
The second step is @ interface. For example, you can see a column on the Internet that uses C # To capture the child's column, for example:
Public class Kids: System
{
Private string kidName = "name ";
Private stringkidAge = "12 ";
Private bool isCaughtKid ()
{
Return true;
}
}
However, it is pointed out in OBJECT_C:
@ Interface Kids: NSObject {
NSString * kidName;
NSString * kidAge;
}
-(BOOL) isCaughtKid
@ End
Next, write a kids. m file for implementation.
# Import "kids. h"
@ Implementation Kids
-(Void) init {
KidName = @ "mykid ";
KidAge = @ "12 ";
}
-(BOOL) isCaughtKid
{
Return YES;
}
@ End
OK. Here is a simple example.
Let's take a look at the problem of passing multiple parameters:
A method can contain multiple parameters, but the names of the parameters are required:
(Method data type) function name: (parameter 1 data type) value of parameter 1 Name of parameter 2 Name: (parameter 2 data type) the name of parameter 2 ......;
For example:
-(Void) setKids :( NSString *) myOldestKidName secondKid :( NSString *) mySecondOldestKidName thirdKid :( NSString *)
MyThirdOldestKidName;
-(Void) setKids: (NSString *) myOldestKidName secondKid: (NSString *) mySecondOldestKidName thirdKid: (NSString *) myThirdOldestKidName {
Eldest Son = myOldestKidName;
Second son = mySecondOldestKidName;
Son 3 = myThirdOldestKidName;
}
 
When calling:
 
 
Kids * myKids = [[Kids alloc] init];
[MyKids setKids: @ "" secondKid: @ "" thirdKid: @ ""];
 
However, if you use c # To write this method, the general statement may be:
 
MyOldestKidName, string mySecondOldestKidName, string myThirdOldestKidName)
{
...
}
 
The calling method may be as follows:
 
Kids myKids = new Kids ();
MyKids. setKids ("Zhang Dali", "Zhang erli", and "Zhang Xiaoli ");
 
Do you understand? In fact, it is not difficult to understand.
 
Basically, if you can understand the Conversion Relationship of the following code, your Objective-C syntax can be roughly achieved:
 
[[MyClass alloc] init: [foo bar] autorelease];
 
The syntax for converting to C # or Java is:
MyClass. alloc (). init (foo. bar (). autorelease ();
3. Other things
 
In fact, the previous articles on this site mentioned this. I will explain it in detail here.
 
1. id:
 
Objective-C has a special data type: id. You can think of it as "casual ". (Equivalent to void * in c *)
 
In Objective-C, everything is saved as a pointer, and you get the location of the object in the memory. So id is the way you know the location, but you don't know what it is.
 
2. Different objects can be saved in the same array:
 
For example, an array NSArray, which can store various objects, such:
 
MyArray <-- |
 
0: (float) 234.33f
1: @ "I am a good guy"
2: (NSImage *)
 
(Meitu)
 
3: @ "I am really a good guy"
 
This is an array composed of four things. This array includes a floating point number, two strings, and an image.
 
3. BOOL, YES, NO:
You can think that YES indicates true in C # or Java, and NO indicates false. In fact, YES is 1, NO is 0, and BOOL itself is a char.
 
4. What are IBOutlet and IBAction.
5. nil.
In Objective-C, NULL indicates a NULL pointer.
 
6. Why @ "string" instead of "string"
 
"String" is a string of C,
@ "String" is a shorthand for converting a C string to an NSString.
This conversion is required only when NSString is needed, for example, in NSLog.
The "string" is used where the C string is required.
In addition, @ "" This conversion does not support Chinese characters. For example, NSLog (@ "string"); it must be unable to output Chinese characters.
 
Iv. Objective-C 2.0
Objective-C 2.0 is a new language of Leopard. It is actually the same as the original Objective-C. Attribute is added. For more information, see Allen Dang's article.
 
? P = 81
 
V. Summary
 
Let's summarize how to read the Objective-C code and how to start learning Objective-C.
 
1. Remember that Objective-C is C. It is critical that it is not a Martian language.
2. Remember that you can't understand it, but it doesn't mean your mind is too dull. Most people may be even slower to read Objective-C code for the first time.
3. Add CocoaChina.com to your favorites. If you do not understand the code, read this article again.
4. The document is critical. When you cannot understand what something is said, check Cocoachina first and then read the API description in the English document, especially when this class starts with NS. If you can't do this, search for google and paste the method you want to check into google. Many people are usually asking the same question. Naturally, some enthusiastic people are willing to help answer this question.
5. You can see the hello world example, but you can't always look at it. It will be dizzy if you look too much. In addition, you must give up the official example of Currency conversion in Apple's Currency Converter, which is a poison. The more you learn, the more you see it.
6. The best way to learn a language is to use it first. Like learning a foreign language, you will naturally read it when you speak. Set up a simple goal for yourself, such as creating a simple program and solving the problem a little bit. In this way, learning is much faster than just looking at examples.
 
This is an article written by a beginner. I hope it will help you a little bit if you are also a beginner :) although it is just a little superficial, it should be helpful for you to enter the door of Objective-C. After reading this article and looking back at other articles in Cocoachina, you will feel very pleasing to the eye. Remember the days.
 
In addition, this Objective-C Reference is also good. If you are interested, you can read it.
 

OK is used as a reference ......
These two things do not actually play a major role in syntax. If you want to see the control object in Interface Builder, add IBOutlet before the definition to see the outlet of this object in IB, if you want to control an object to execute certain actions in Interface Builder, add (IBAction) before the method ).
 
These two things are actually the same as void.

 


From low profile

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.