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.