Object-C, Object and Method

Source: Internet
Author: User

Object-C, Object and Method

I learned Object-C and bought two books. One of them was bought in C currency. The overall quality is average and the comparison is basic.

Another one is crazy-written by Li Yang. It's scary and comprehensive.

I have a rough understanding of object-oriented, and I will give more basic examples.

 

Currently, the least habit is that there are multiple parameter methods. This is quite different from the C-series language.

 

Code

 

/// Main. m // ObjectPerson // Created by fansunion on 15/12/3. // Copyright (c) 2015 demo. All rights reserved. // # import
 
  
# Import "Person. h "// # import" Person. m "int main (int argc, const char * argv []) {@ autoreleasepool {// construct object Person * person = [[Person alloc] init]; // call the instance method of 1 parameter [person say: @ "I am FansUnion"]; // call the instance method of 2 parameters [person setName: @ "Xiao Lei FansUnion" andAge: 26]; // call the [person info] Method of the instance without parameters; // call the class method without parameters [Person bye];} return 0 ;}
 

 

Running result

 

20:57:39. 023 ObjectPerson [6193: 440740] I am test method

20:57:39. 025 ObjectPerson [6193: 440740] Hi, I am FansUnion

20:57:39. 025 ObjectPerson [6193: 440740] I am info method

20:57:39. 025 ObjectPerson [6193: 440740] bye!

Program ended with exit code: 0


The example is relatively simple.

I'm off duty today and will continue in the next day.

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.