Đây là tiện dụng cho hành vi đó là không bị ràng buộc một đối tượng cụ thể, nhưng là toàn cầu đến lớp. Ví dụ tốt nhất của loại thông báo phân bổ một đối tượng mới. Khi bạn muốn có một vòng tròn mới, nó phù hợp với yêu cầu lớp Circle cho rằng đối tượng mới, chứ không phải là yêu cầu một vòng tròn hiện có. | 88 CHAPTER 6 Source File Organization The other part of a class s source is the implementation. The implementation section tells the Objective-C compiler how to make the class actually work. This section contains the code that implements the methods declared in the interface. Because of the natural split in the definition of a class into interface and implementation a class s code is often split into two files along the same lines. One part holds the interface components the interface directive for the class any public struct definitions enum constants defines extern global variables and so on. Because of Objective-C s C heritage this stuff typically goes into a header file which has the same name as the class with a .h at the end. For example class Engine s header file would be called and Circle s header file would be . All the implementation details such as the implementation directive for the class definitions of global variables private structs and so on go into a file with the same name as the class and a .m at the end sometimes called a dot-m file . and would be the implementation files for those classes. NOTE__ If you use .mm for the file extension you re telling the compiler you ve written your code in Objective-C which lets you use C and Objective-C together. Making New Files in Xcode When you build a new class Xcode makes your life easier by automatically creating the .h and .m files for you. When you choose File New File in Xcode you get a window like the one shown in Figure 6-1 that presents you with a list of the kinds of files that Xcode knows how to create. Select Objective-Cclass and click Next. You ll get another window asking you to fill in the name as shown in Figure 6-2. You can see a bunch of other things in that window. There s a checkbox you can use to have Xcode create for you. If you had multiple projects open you could use