What about Xcode development and learning?

Source: Internet
Author: User

AboutXcode DevelopmentThis document describes the things you want to learn.Xcode DevelopmentSome notes frequently used in the process, so that we can share them with you here.Xcode Development. Let's just look at the content first.

1. Apple's program is the same as ordinary C program. Each program must contain the main () function.

2. Do not use "NS" as the prefix for your own class name to avoid confusion.

NS is dedicated to Apple's own class, which represents NeXTStep. Mac OS X was developed based on the NeXTStep operating system. Apple acquired NeXT, which brought Steve Jobs back to Apple and took the first place.

3. Among all classes, top-level classes are called "object classes" NSObject.

Almost all the classes you create or use are directly or indirectly the "subclass" subclass of the object class ). For example, the class NSWindow is a subclass of the class NSResponder, and the class NSResponder is a subclass of the class NSObject.

4. Cocoa screen input function:

 
 
  1. NSLog(@"Julia is a pretty actress."); 

Use the @-enabled string to represent the Objective-C string

Object c contains header files # import

For example:

 
 
  1. #import <Foundation/Foundation.h> 

5. The main window for XCode development is divided into two parts:

The left column is "Groups & Files", which is used to process the various material Files that make up your entire program. At present, there is not much content here. When you start to write multi-language graphics programs, you will find the graphic interface program and multi-language program in this column. It may be difficult to search for scattered material files one by one on the hard disk. Xcode provides the virtual folder called "Group") concept, material files are classified and stored in these Groups to help you organize the materials conveniently.

The interface resource file is a nib file, similar to the resource editor developed by Windows. Cocoa-Controls is called a "Palette", similar to the resource toolbox developed by Windows. It stores various objects that can be used on your image interface. When you move the cursor over a control, the Class Name of the control is displayed. Select an object and use command-shitf-I to modify its attributes.

6. After creating window interface resources, you need to create a class for the window:

On the nib file page of the window, select the "Classes" tab. In the first column, you will see "NSObject ". Select it, and select "Subclass NSObject" in the "Classes" menu ". After creating a class MyClass, return to the interface editing interface and select "Instantiate MyClass" from the Classes menu. There is a new icon called MyClass. This icon represents the instance of the class we just created.

7. to associate the message processing contacts of controls and classes.

Now, you can set up the association between a widget and the modified class on the Interface: click the "Instances" tab in the "*. nib" window. Press and hold the Ctrl key on the keyboard and drag the "control" to the instance of MyClass. Do not use other methods to create associations !) A line representing the link is displayed on the screen. Make sure that the line is connected to the instance of MyClass from the button and you can release the mouse.

When you release the mouse, the associated palette is displayed in the View window. The methods available in the object MyClass are listed in the palette. Select the correct method and click Connect to complete the association process.

Of course, these methods must be added to MyClass in advance.

8. Cocoa has a very important awakeFromNib function.

When the window opens, the awakeFromNib method is automatically called. This method is useful when initializing the window status.

9. String:

A string created by the NSString class is called a fixed string because it cannot be modified. What are the advantages of strings that cannot be modified? It should be said that such strings are easier to process for the operating system, so your program can run faster.

 
 
  1. NSString * foo;  
  2. foo = @"Julia!"; 

Sometimes you do want to modify them. You can use another class -- NSMutableString

 
 
  1. NSMutableString *foo;   
  2. foo = [@"Julia!" mutableCopy];   
  3. [foo appendString:@" I am happy"]; 

Method mutableCopy provided by NSString class) copies a new variable string as the receiver of method information.

10. array:

Two classes provide Arrays: NSArray and NSMutableArray. Arrays with strings can be divided into fixed arrays and variable arrays.

 
 
  1. [NSMutableArray array] 

This statement will generate an empty array

 
 
  1. NSMutableArray *myArray = [NSMutableArray array];  
  2. [myArray addObject:@"first string"];  
  3. [myArray addObject:@"second string"];  
  4. [myArray addObject:@"third string"];  
  5. int count = [myArray count];  
  6. NSLog(@"There are %d elements in my array", count); 

ReplaceObjectAtIndex :... WithObject :...".

 
 
  1. [myArray replaceObjectAtIndex:1 withObject:@"Hello"]; 

Memory Management:

To help you process objects that are not in use,CocoaEach object is associated with a counter, which is called a "Reserved counter ". When programming, add a quote information to the object, so that the object must be added to its counter. When one quote is removed, the value is reduced by one. When the counter count of the reserved counter is 0, the object will know that it is no longer quoted and can be destroyed safely. At this time, the object will destroy itself and release the memory space.
 
11. Develop common website resources:

Apple developer homepage:

 
 
  1. http://www.apple.com/developer。  
  2. http://osx.hyperjeff.net/reference/CocoaArticles.php  
  3. http://www.cocoadev.com/  
  4. http://www.cocoabuilder.com/  
  5. http://www.stepwise.com/ 

The above websites also provide a large number of links to other resources. You should also subscribe"Cocoa-Dev "mail list web site http://lists.apple.com/mailman/listinfo/cocoa-dev ). Here you can ask questions, and enthusiastic netizens will always do their best to help you solve the problem.

Of course, you should pay attention to courtesy, and should first try to solve the reference http://www.cocoabuilder.com/) http://www.catb.org /~ The "How To Ask Questions The Smart Way" on The esr/faqs/smart-questions.html page shows you How To properly Ask Questions.

There are also some excellentCocoaDeveloped books. The Programming in Objective-C prepared by Stephen Kochan is for beginners. Other books require you to have the basic knowledge that this book will provide. We recommend Cocoa Programming for Mac OS X, which is written by Aaron Hillegass. He is teaching Big Nerd Ranch. We also recommend you to the Cocoa withObjective-C book published by o'reilly, jointly written by James Duncan David son and apple.

Summary: AboutXcode DevelopmentI hope this article will help you understand the content of those things!

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.