探索Objective - C扩展与面向对象编程基础
1. Objective - C扩展中的BOOL类型与函数
在Objective - C编程里,我们可以构建并运行程序。若要查看程序输出,可选择“View ➤ Debug Area ➤ Activate Console”,或者使用快捷键⌘⇧R来调出控制台。运行程序后,输出可能如下:
2012 - 01 - 20 16:47:09.528 02 BOOL Party[16991:10b] are 5 and 5 different? NO
2012 - 01 - 20 16:47:09.542 02 BOOL Party[16991:10b] are 23 and 42 different? YES
The Debugger has exited with status 0.
下面我们逐个分析程序中的函数。
1.1 areIntsDifferent()函数
BOOL areIntsDifferent (int thing1, int thing2)
{
if (thing1 == thing2) {
return (NO);
} else {
return (YES);
}
}
此函数接收两个整数参数,返回一个BOOL值。它对比 thing1 和 thing2 ,若二者相同则返回 NO ,不同
超级会员免费看
订阅专栏 解锁全文
43

被折叠的 条评论
为什么被折叠?



