Quick Start for Mac development

Source: Internet
Author: User

First contact with the development of the Mac, found that the domestic relevant information is very poor, so write this article, as a study record. Mac App Development is also developed using OBJECTIVE-C, so it's not difficult to switch from iOS to Mac, and many things are the same.

This article takes a login interface as an exercise

All right, cut the crap.

First, the new project

Then select the project save path and click Create.

And then we can see an interface like this

Ii. Use of controls

Click the text box, Ctrl-Drag to the middle of @interface and @end, pop-up the Binding property box, enter the property name, and click Connect.

For a button, the type of connection should select action.

Then click on the top right corner to switch to a single editing interface

At this point, we have completed the creation of project projects and the binding of controls.

If you are familiar with iOS programming, you may be able to find a pattern here. Many of the user interface-related classes in Uikit are migrated from OSX AppKit. So, some of them just changed from the prefix NS in the Mac to the UI in iOS.

Third, the operation of the control

We can see in the viewcontroller.m file that there is a method named Loginbtn: This is the callback of the login button and we can do something about that method.

1 -(ibaction) LOGINBTN: (Nsbutton *) Sender {2     NSLog (@ "usernmae:%@ " , self.userName.stringValue); 3     NSLog (@ "password:%@", self.password.stringValue); 4 }

We enter the above code, and when you click the login button, the contents of the Username and password text boxes are output in the console.

Press Commend+r to run the program, enter the content in the text box, click Login, and the contents of the text box will be printed in the console.

This concludes the tutorial, where we only learned how to create engineering and bound controls and very few UI actions. If you are familiar with iOS programming, this tutorial may not be an egg for you ...

To continue learning about UI, you can continue to view UI-related articles.

Quick Start for Mac development

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.