my journey of developing iOS app begins
来源:互联网 发布:nginx tomcat负载均衡 编辑:程序博客网 时间:2024/06/07 10:06
Objective-C has an important type called id
Is it safe?
It means “pointer to an object of unknown/unspecified” type.
id myObject;
Really allobject pointers (e.g. NSString *) are treated like id at runtime.
But at compile time, if you type something NSString *instead of id, the compiler can help you.
It can find bugs and suggest what methods would be appropriate to send to it, etc.
If you type something using id, the compiler can’t help very much because it doesn’t know much.
Figuring out the code to execute when a message is sent at runtimeis called “dynamic binding.”
Treating all object pointers as “pointer to unknown type” at runtime seems dangerous, right?
What stops you from sending a message to an object that it doesn’t understand?
Nothing. And your program crashes if you do so. Oh my, Objective-C programs must crash a lot!
Not really.
Because we mostly use static typing (e.g. NSString *) and the compiler is really smart.
Is it safe?
It means “pointer to an object of unknown/unspecified” type.
id myObject;
Really allobject pointers (e.g. NSString *) are treated like id at runtime.
But at compile time, if you type something NSString *instead of id, the compiler can help you.
It can find bugs and suggest what methods would be appropriate to send to it, etc.
If you type something using id, the compiler can’t help very much because it doesn’t know much.
Figuring out the code to execute when a message is sent at runtimeis called “dynamic binding.”
Treating all object pointers as “pointer to unknown type” at runtime seems dangerous, right?
What stops you from sending a message to an object that it doesn’t understand?
Nothing. And your program crashes if you do so. Oh my, Objective-C programs must crash a lot!
Not really.
Because we mostly use static typing (e.g. NSString *) and the compiler is really smart.
0 0
- my journey of developing iOS app begins
- My First journey of blog
- My hardwork begins.....
- iOS: 今天开始App(Start Developing iOS Apps Today)
- ios开发之开发文档 start developing ios app
- Where my journey starts
- A MAP OF THE ENTERPRISE APP DEVELOPER JOURNEY
- Developing a VoIP App
- Guideline of developing Drizzle
- MY FIRST CET-6 journey
- 马上着手开发 iOS 应用程序 (Start Developing iOS Apps Today)——App Store
- URL for iOS developing
- 【Python学习之路】My first journey
- 【Python学习之路】My second journey
- 【Python学习之路】My Third journey
- 【Python学习之路】My Forth journey
- The Journey of ArchLinux Installation
- Our Journey of Dalian Ends
- Java基础视频教程第09天_面向对象之内部类、异常1
- C++ The Bisection Method
- poj 3254 Corn Fields 状态压缩dp
- 为什么要学习Numerical Analysis
- 使用UltraISO制作U盘Win7安装盘,出现"File not find /BOOT/CDMENU.EZB.ezb"错误
- my journey of developing iOS app begins
- HDU 1686--Oulipo【KMP】
- Matlab The Bisection Method
- Linux下制作系统启动U盘
- 错误总结2
- 二分法 具体操作
- OpenGL学习笔记之配置OpenGL
- 数据结构中的栈
- 对左值和右值的理解