Introduction to the Mac OS Cocoa framework

Source: Internet
Author: User

DetailsMac OS Cocoa frameworkThe overview is the content to be followed in this article.Cocoa framework. This article mainly describes how to get started with programmers who have changed from linux Command Line programmers.

1. When writing code in linux Command lines, you only need to know a few system calls and libc library functions to 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, in cocoa, the 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 in 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 sole 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. mac/ios programs are generally developed using 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, others will need to learn the classes provided by cocoa and think about how to combine these classes to complete their work, it is a building block process.

Summary: DetailsMac OS Cocoa frameworkThe overview is complete. I hope this article will help you!

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.