iOS Basics (ii) objects

Source: Internet
Author: User

Use the foundation framework when writing OBJECTIVE-C programs.

What is a framework?

A framework is a library of many classes (class) that you can use to write programs.

Object (Object)

    • objects can hold data and can contain a set of functions.
    • The function can use the data saved by the object.
    • A function that sends a message to an object that can be used to start a response.
    • This type of message-based function is called method.

I. Creation of the first OBJECTIVE-C program

Creating a project, create a new Xcode project, OS X under Application, Command line Tool, named Firstoc, as shown in:

For files that contain object-c code, the suffix. M is generally used. Find main.m in Xcode and open and enter the following lines of code:

#import <Foundation/Foundation.h>int main (intconstChar *  Argv[]) {    @autoreleasepool {             NSLog (@ "Hello, world! " );                 *now = [NSDate date];        NSLog (@ "Thedate is%@"  , now);    }         return 0 ;}

Build and run. The output is roughly as follows:

 --Geneva- -  -: -:36.130firstoc[67855:3381337] Hello, world! --Geneva- -  -: -:36.135firstoc[67855:3381337] the date is  --Geneva- -  A: -: $+0000

NSLog () is a powerful output function provided by the foundation, which can output not only strings, but also integers, C-cell strings and Objective-c objects.

<1> its first argument is a string constant, which is populated with the corresponding variable by using the%-format placeholder in the string.

Format characters supported by the NSLog () function

Format characters Description
D output integers in decimal form
O Output integers in eight binary form
X Output integers in 16 binary form
@ Output OC Object

iOS Basics (ii) objects

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.