CocoaBasicFrameworkIs the main content of this article,Cocoa/CocoaTouchFrameworkYesMac/IOSThe most popularFramework. I will not talk much about the advantages. I will mainly talk about how to get started with programmers who have changed from Linux Command Line programmers.
1. When writing code in a linux Command Line, you only need to know a few system calls and the library functions of libc, and you can write the code as you like to complete the required functions. HoweverCocoaThey are self-contained and can run the complete code. We don't add a line of code, and they can run normally.
That is to say, inCocoaThe main framework of the program is fixed and cannot be modified by the programmer. What the programmer needs to do is to add "hook" to the place specified by cocoa ", only by adding our own code to these hooks can the cocoa framework call our own code to implement various functions. Cocoa programming is actually a process that adds bricks to the cocoa framework.
2. programming on the graphic interface introduces a new concept called design pattern. The name is very abstract, but specifically, it is a programming method created to solve a certain problem. For example, in cocoa, the most important modes are MVC, delegate, target-action, and so on. These modes are designed to solve certain programming problems, such as MVC, to solve graphical programming, to make the design of the class clearer, the delegate is a design mode to facilitate the expansion of a control class controller class.
This may be hard to understand. If you are familiar with the cocoa tutorial, you will find that understanding various design pattern is the key to understanding cocoa, because these design patter explains where to add your own code and why to add code again.
3. In the cocoa framework, the program driver is a variety of messages, that is, the only purpose of the program is to respond to the messages produced by the system or the user's operations on the interface. For the message delivery path, refer to apple's cocoa fundamentals guide. So how do various classes correspond to these messages? That is, how do we add our hooks to this framework )? The following methods are used:
Extends the view control by using sub class, and reloads or adds new message response functions.
Expand the view control through delegate, because after the view obtains the message, it will also pass the message to its own delegate notification centers, etc.
4. Developing mac/ios programs generally uses xcode + interface builder. What is the relationship between the two programs? In short, xcode is the source code editing environment, while interface builder is the runtime editor. Why? Let's recall what we were doing during programming? Define object template declaration class) + generate objects + process relationships between objects.
These actions can be completed by coding in the xcode environment. Why do I need to use interface builder? Interface builder is actually used to complete the last two tasks, that is, to generate an object + process the relationship between objects. Interface build has a natural advantage in processing these two tasks, that is, it can be done by graphical drag and drop. Therefore, it is intuitive and convenient to use it to create the objects involved in the program interface.
Cocoa frameworkThis is the entry-level knowledge. After mastering these things, other things will need to be learned.CocoaProviding classes and thinking about how to combine these classes to complete their work is a building block process.
Summary: DetailsMac OS CocoaBasicFrameworkI hope this article will help you!