Object-c, objects and methods

Source: Internet
Author: User

Study Object-c, bought 2 books, of which 1 were bought with C money, general quality, comparative basis.

The other one is, crazy-Li Yang wrote, tome, more scary, compared to a whole bit.

For object-oriented, there is a general understanding, and then a few more basic examples.


At present, using the most unaccustomed is, there are multiple parameters of the method. This and the C-series language, very different, really uncomfortable ah.


Code

  main.m//  objectperson////  Created by fansunion on 15/12/3.//  Copyright (c) 2015 demo. All rights reserved.//#import <Foundation/Foundation.h> #import "Person.h"//#import "person.m" int main (int argc, const char * argv[]) {    @autoreleasepool {        //Construction object        person* person = [[Person alloc]init];        Invokes an instance method of 1 arguments        [person say:@ "I am Fansunion"];        Call an instance method of 2 arguments        [person setName: @ "Ray Fansunion" andage:26];        Call an instance method with no arguments        [person info];        Call a class method without arguments        [person bye];             }    return 0;}

Run results

2015-12-03 20:57:39.023 objectperson[6193:440740] I am test method

2015-12-03 20:57:39.025 objectperson[6193:440740] hi,i am fansunion

2015-12-03 20:57:39.025 objectperson[6193:440740] I am Info method

2015-12-03 20:57:39.025 objectperson[6193:440740] Bye bye!

Program ended with exit code:0


The example is relatively simple.

We are off work today and continue tomorrow.

Object-c, objects and methods

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.