. h : Header file. Header files contain declarations of classes, types, functions, and constants.
. M : source code file. This is a typical source code file extension that can contain objective-c and C code.
. MM : source code file. Source code files with this extension can contain C + + code in addition to the objective-c and C code. This extension is only used when you really need to use C + + classes or features in your objective-c code.
You can use standard #include compilation options when you need to include header files in your source code, but objective-c provides a better approach. The #import option is identical to the #include option, except that it ensures that the same file will only be included once.
#import <Foundation/Foundation.h>
OC recommended with #import contains header files, C-language method of # include can also
Foundation Framework
The include file is the same as C, and the user of the <> system
Key words
@interface,@implementation,@end
@public, @protected,@private,@selector
@try,@catch,@throw,@finally
@protocol,@class
Self, id, super, _cmd, _block, _strong, _weak (does not start with @)
The new keywords introduced in OC 2.0 have
@property,@synthesize
@optional,@required,@dynamic
The program entry is also a main function
The nslog function is defined as the form of C .
is a log output function that outputs incoming OC string parameters to the console
Automatic line wrapping after output is complete
Support for format characters:
*%f means to receive floating-point data,%.2f means to retain 2 decimal places
The format of the NSLog is as follows:
%@ |
Object |
%d,%i |
integer |
%u,%z |
No character shaping |
%f |
floating point / double word |
%x,%x |
hexadecimal integer |
%o |
octal integer |
%zu |
size_t |
%p |
pointer |
%e |
floating / double word (scientific calculation) |
%g |
floating point / double word |
%s |
c character String |
%.*s |
pascal string |
%c |
character |
%c |
unichar |
%lld |
64 bit long integer ( long Long |
%llu |
no 64 bit long integer |
%lf |
64 bit double word |
%hhd |
BOOL Boolean type |
NSLog (@ "Hello World");//The string starts with @ in OC
#import <foundation/foundation.h>int Main () { NSLog (@ "Hello world"); return 0;}
OC Language Learning (i) Hello world