读书时间 2011/06/17 - 2 Objective-C

本文档介绍了Objective-C的基础知识,包括语法特点、对象通讯方式、方法声明等,并深入探讨了类的定义、实例化过程及初始化方法。同时,文章还讨论了Objective-C作为动态语言的特性及其在iOS开发中的应用。

《Objective-C基础教程》

 

0. 杂记杂问

 

Q: 对象通讯总使用指针,所以,有没有这样的变量申明 Car car ????

Q: Objective-C++什么含义?

Q: -的含义?

-(void) draw;  // "-"表示此为方法申明,这是一种区分函数原型与方法申明的方式,后者者"-"

                     Q: "-"似乎表示instance method,与"+"对应,后者表示class method 2011/12/20

 

* iphone/ipad开发视频:http://6.cn/watch/14587346.html

 

 

1. chap 2.

* #import

可以处理重复引入*.h的问题

 

* @"Hello World!"完全不同于"Hello World!",前者类型是NSString,后者类型为char *

 

* BOOL

比C的bool还老,但YES/NO定义与C之true/false完全不同 

 

2. chap 3

 

* 接口与实现

@interface

@implementation

 

* 方法名:经常都会有":",如果有参数

example: setFillColor:

 

* 类访问属性

没有访问属性概念,也就没有private概念,原因是Objective-C是一个动态语言的副作用。

Q:Objectivc-C的动态语言特性还体现在什么地方?

 

* 实例化类

example:

shape[0] = [Circle new];

 

* self参数 = this

 

3. Chap4 继承

* 不支持多继承

Q: P54, 基地址+偏移:leopard???

 

* Super关键字

Q 方法调度机制:与C++的虚函数表比究竟有何区别?

    A:C++是通过函数指针访问相关方法,Ojbective-C如何呢?2011/12/21

 

4. Chap5 复合

Q:-(NSSTring *)description{}; 是在NSObject中定义的?

      A:Yes, I think so. 2011/12/21

* Car类例子

@interface Car : NSObject

{

    Engine *engine;

   Tire* tires[4];

}

 

@Implementation Car

 

-(id)init

{

 

    if(self=[super init]) {

        engine = [Engine new];

        tires[0] = [Tire new];

        ...

        return self;

} // init

 

-(void) print

{

    NSLog(@"%@", engine);   // Engine的descrption()方法被调用

    NSLog(@"%@", tries[0]);

    ...

}

 

int main(int argc, const char* argv[])

{

    Car * car;

    car = [Car new];

    [car print];

    return (0);

} // main

 

注:new一个Car时,完成两步:

# 分配内存空间

# 自动调用init

 

* 存取方法

 

* 命名惯例

getter: property

setter: setProperty

Q: 方法名中get的特别含义? 2011/12/21

 

* 中缀方法名

-(void) setTier: (Tier *)tier

           atIndex:(int) index

{

    ...

}

 

调用:

Tire * tire = [Tire new];

[car setTire: tire at Index: 2]

 

* @class 向前引用???

Q:导入与超类??? P79

 

5. Chap8 Foundation Kit快速教程

 

* 类方法

+的含义?

+(id) stringWithFormat:(NSString*) format, ...;

^ 类方法,相当于Java的静态方法

                                                                     ^ 参数数目不定

使用:

[NSSTring stringWithFormat:format, x,y];

 

 

 

下载方式:https://renmaiwang.cn/s/t0445 在时序发生器设计实验中,如何达成T4至T1的生成? 时序发生器的构建可以通过运用一个4位循环移位寄存器来达成T4至T1的输出。 具体而言:- **CLR(清除)**: 作为全局清零信号,当CLR呈现低电平状态时,所有输出(涵盖T1至T4)皆会被清除。 - **STOP**: 在T4脉冲的下降沿时刻,若STOP信号处于低电平状态,则T1至T4会被重置。 - **启动流程**: 当启动信号START处于高电平,并且STOP为高电平时,移位寄存器将在每个时钟的上升沿向左移动一位。 移位寄存器的输出端对应了T4、T3、T2、T1。 #### 2. 时序发生器如何调控T1至T4的波形形态? 时序发生器通过以下几个信号调控T1至T4的波形形态:- **CLR**: 当CLR处于低电平状态时,所有输出均会被清零。 - **STOP**: 若STOP信号为低电平,且在T4脉冲的下降沿时刻,所有输出同样会被清零。 - **START**: 在START信号有效(通常为高电平),并且STOP为高电平时,移位寄存器启动,从而产生环形脉冲输出。 ### 微程序控制器实验#### 3. 微程序控制器实验中的四条机器指令及其对应的微程序段指定的机器指令及其关联的微程序段如下:- **NOP**: 00- **R0->B**: 04- **A+B->R0**: 05- **P<1>**: 30- **IN->R0**: 32- **R0->OUT**: 33- **HLT**: 35#### 4. 微程序段中的微操作/微命令序列针对每条微指令,其对应的微操作或微命令序列如下:- **IN->R0**: 输入(IN)单元的数据被...
====== 滚动窗口 1/21 [时段 1-16] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1156 rows and 466 columns. MIQP Presolve modified 616 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 174 rows, 96 columns, and 348 nonzeros. Reduced MIQP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators. Reduced MIQP objective Q matrix has 96 nonzeros. Presolve time = 0.00 sec. (2.85 ticks) Tried aggregator 1 time. MIQP Presolve eliminated 145 rows and 80 columns. Reduced MIQP has 29 rows, 16 columns, and 58 nonzeros. Reduced MIQP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators. Reduced MIQP objective Q matrix has 16 nonzeros. Presolve time = 0.00 sec. (0.08 ticks) Tried aggregator 1 time. Reduced MIQP has 29 rows, 16 columns, and 58 nonzeros. Reduced MIQP has 0 binaries, 0 generals, 0 SOSs, and 0 indicators. Reduced MIQP objective Q matrix has 16 nonzeros. Presolve time = 0.00 sec. (0.02 ticks) MIP emphasis: balance optimality and feasibility. MIP search method: dynamic search. Parallel mode: deterministic, using up to 12 threads. Node log . . . Best integer = 1.149757e+04 Node = 0 Best node = 1.149757e+04 + Calling CPLEX-IBM 优化成功 | 窗口成本: 19013.97 元 ====== 滚动窗口 2/21 [时段 5-20] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1330 rows and 562 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. All rows and columns eliminated. Presolve time = 0.00 sec. (2.60 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 警告:时段 5 存在爬坡约束违反 (最大违反 32.00 MW) ====== 滚动窗口 3/21 [时段 9-24] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1330 rows and 562 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. All rows and columns eliminated. Presolve time = 0.00 sec. (2.77 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 4/21 [时段 13-28] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1330 rows and 562 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. All rows and columns eliminated. Presolve time = 0.00 sec. (2.73 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 5/21 [时段 17-32] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.90 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 6/21 [时段 21-36] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.86 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 7/21 [时段 25-40] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.87 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 8/21 [时段 29-44] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.86 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 9/21 [时段 33-48] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.86 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 10/21 [时段 37-52] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.90 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 11/21 [时段 41-56] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.82 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 12/21 [时段 45-60] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.01 sec. (2.90 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 13/21 [时段 49-64] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.78 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 14/21 [时段 53-68] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.94 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 15/21 [时段 57-72] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.78 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 16/21 [时段 61-76] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.94 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 17/21 [时段 65-80] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.73 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 18/21 [时段 69-84] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.02 sec. (2.90 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 19/21 [时段 73-88] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.02 sec. (2.82 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 20/21 [时段 77-92] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.90 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元 ====== 滚动窗口 21/21 [时段 81-96] ====== + Solver chosen : CPLEX-IBM + Processing objective function + Processing constraints CPXPARAM_MIP_Display 1 Tried aggregator 3 times. MIQP Presolve eliminated 1298 rows and 498 columns. MIQP Presolve added 16 rows and 0 columns. MIQP Presolve modified 724 coefficients. Aggregator did 448 substitutions. Reduced MIQP has 48 rows, 64 columns, and 127 nonzeros. Reduced MIQP has 16 binaries, 0 generals, 0 SOSs, and 0 indicators. Presolve time = 0.00 sec. (2.86 ticks) + Calling CPLEX-IBM 优化成功 | 窗口成本: 7516.40 元
11-28
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值