OC视频教程29课-第02讲 1、2 Objective-C 类的使用
来源:互联网 发布:游族网络董事长 编辑:程序博客网 时间:2024/05/22 08:22
第02讲 1、2 Objective-C类的使用
声明部分:
#import <Foundation/Foundation.h> //foundation |faʊnˈdeɪʃn| noun地基、基础
@interface Circle : NSObject
{
int radius;
int x;
int y;
}
//circle |ˈsɜːkl| noun圆
@property (nonatomic) int radius,x,y;
//radius |ˈreɪdɪəs| noun半径
-(void)print;
@end
实现部分:
#import “Circle.h”
@implementation Circle
@synthesize radius; // synthesize |ˈsɪnθəsaɪz| v合成、综合
- (void)print
{
NSLog(@“radius:%d”,radius);
}
@end
Implementation Section
General Format
@implementation className
Synthesized Property
methodDefinition
methodDefinition
….
@end
Unless the methods for a category are being implemented. all the methods declared in the interface section must be defined in the implementation section.
If one or more protocols were listed in the interface section,all the protocols’ methods must be defined.
Method Definition
General Format
myType (returnType) name1:(type1)param1 name2:(type2)param2…
{
variableDeclarations
…
Return expression;
} //declare |dɪˈkleə(r)| v 宣告、宣布、声明;declaration |ˌdekləˈreɪʃn| n
This method declaration must be consistent with the corresponding method declaration from the interface section or from a previously defined protocol definition.
consistent |kənˈsɪstənt| adj一贯的、始终如一的;correspond |ˌkɒrɪˈspɒnd, American ˌkɔːr-| v 相符、相当。corresponding相关的;
An instance method can reference the class’s instance variables and any variables it has inherited directedby name.If a class method is being defined, it cannot reference any instance variables.
inherit |ɪnˈherɪt| verb继承
The identifier self can be used inside a method to reference the object on which the method was invoked.
- OC视频教程29课-第02讲 1、2 Objective-C 类的使用
- OC视频教程29课-第01讲 Classes
- 中科院Java高端培训视频教程第02讲-C
- OC: 第一讲(Objective-C,面向对象的C语言)
- 中科院Java高端培训视频教程第03讲-C
- 中科院Java高端培训视频教程第04讲-C
- 中科院Java高端培训视频教程第06讲-C
- 中科院Java高端培训视频教程第08讲-C
- 中科院Java高端培训视频教程第09讲-C
- 中科院Java高端培训视频教程第10讲-C
- 中科院Java高端培训视频教程第11讲-C
- 中科院Java高端培训视频教程第12讲-C
- 中科院Java高端培训视频教程第14讲-C
- 中科院Java高端培训视频教程第16讲-C
- 中科院Java高端培训视频教程第17讲-C
- 中科院Java高端培训视频教程第18讲-C
- Objective - C基础: 第一天 - 1. 第1, 2个OC程序
- 【Objective-C】OC中类的继承
- 基于android的Socket通信
- JVM整体结构图解
- fsharp处理Excel数据
- 三天完成小应用 大开天气——通过省市县数据库来制作城市选定页面
- python set operation
- OC视频教程29课-第02讲 1、2 Objective-C 类的使用
- 开发中遇到的问题总结
- c++引用高级学习-引用函数指针
- Spring官网改版后下载Spring方法
- 顺序表的实现
- Qt 解析Json
- mssql数据迁移到mysql
- erlang 多种方法接入远程shell控制台
- sax解析xml