Programming in Objective-C 学习笔记01

PART I —— The Objective-C Language(ch.2-4)

  • 在Obj-C中,一个class包含两部分:
    @interface:继承关系,{实例变量},方法声明
    @implementation:@interface中声明的方法的实现代码
  • 命名:
    • 基础规则:
      • 选择范围:下划线,字母,数字0-9
      • 不能以数字开头
      • 不能选择关键字
      • Obj-C大小写敏感
    • 好的原则:
      • class name 首字母大写
      • variable name和method name首字母小写
      • method name 以动词开头
  • 创建对象的过程(三步走)
    • Step1:建立指向待新建对象的引用(对应class的类型,在Stack)
    • Step2:向class发送分配内存空间(Heap)的消息(alloc),返回相应的内存地址给变量,实现引用与对象的绑定
    • Step3:向对象发送初始化的消息(init),返回初始化后的可用对象
  • Data Encapsulation 数据封装
    • class外的方法不能直接读写class中声明的instance variables,而是通过getters和setters方法(都在class中定义)来读和写 =>阻止意外访问
    • setters方法不需要返回值;getters方法一定要有返回值
  • 一种特殊的数据类型(泛型) Type id
    • 用于存储任何类型的对象,通用对象类型
    • The id type is the basis for very important features in Objective-C known as polymorphism and dynamic binding
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Book Description Updated for OS X 10.9 Mavericks, iOS 7, and Xcode 5 Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming for Apple’s iOS and OS X platforms. The book makes no assumptions about prior experience with object-oriented programming languages or with the C language (which Objective-C is based upon). Because of this, both beginners and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C. Readers can also learn the concepts of object-oriented programming without having to first learn all of the intricacies of the underlying C programming language. This unique approach to learning, combined with many small program examples and exercises at the end of each chapter, makes Programming in Objective-C ideally suited for either classroom use or self-study. This edition has been fully updated to incorporate new Objective-C features and technologies introduced with Xcode 5, iOS 7, and Mac OS X Mavericks. “The best book on any programming language that I’ve ever read. If you want to learn Objective-C, buy it.”–Calvin Wolcott “An excellent resource for a new programmer who wants to learn Objective-C as their first programming language–a woefully underserved market.”–Pat Hughes Table of Contents Chapter 1. Introduction Part I: The Objective-C Language Chapter 2. Programming in Objective-C Chapter 3. Classes, Objects, and Methods Chapter 4. Data Types and Expressions Chapter 5. Program Looping Chapter 6. Making Decisions Chapter 7. More on Classes Chapter 8. Inheritance Chapter 9. Polymorphism, Dynamic Typing, and Dynamic Binding Chapter 10. More on Variables and Data Types Chapter 11. Categories and Protocols Chapter 12. The Preprocessor Chapter 13. Underlying C Language Features Part II: The Foundation Framework Chapter 14. Introduction to the Foundation Framework Chapter 15. Numbers, Strings, and Collections Chapter 16. Working with Files Chapter 17. Memory Management and Automatic Reference Counting (ARC) Chapter 18. Copying Objects Chapter 19. Archiving Part III: Cocoa, Cocoa Touch, and the iOS SDK Chapter 20. Introduction to Cocoa and Cocoa Touch Chapter 21. Writing iOS Applications Appendixes Appendix A. Glossary Appendix B. Address Book Program Source Code Book Details Paperback: 576 pages Publisher: Addison-Wesley Professional; 6th Edition (December 2013) Language: English ISBN-10: 0321967607 ISBN-13: 978-0321967602

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值