Stanford CS193p iPhone Application Development:Lecture 1

     From day on,I'm Learning the CS193p 2013 Fall.I will use English to record the class notes and Chinese to summary them.

    Course Home

1.in Objective-C all objects.all of them, live in heap and we have pointer to them.There are no such thing as making an object on the stack.heap is where you allocate free memory.all of them there.

2.Nil is the same as zero.It does’t point anything.
3. nonatomic means:”access to this property is not thread-safe”.
4.synthesize:that’s basically just saying under bar contents is the name of instance variable
5.there properties don’t need the strong or weak,because they’re primitive types.they are not stored in the heap.there’s no memory to manage.but they can nonatomic,we still want the setter and the getter to be simple,not having any locking code or any of that business.
6.property:accessing instance variables directly 
7.All properties, in Objective-C,all of them,start off zero.so int i=0 can replace of int i;for pointer,that’s nil
8.We only use the dot notation for properties.That’s how we call the setter and getter of properties,using dot notation.card.contents is calling the getter of contents property on the card instance.
9.isEqualToString VS ==
10.MVC:
Controllers can always talk directly to their Model.
Controllers can also talk directly to their View
The Model and View should  never speak to each other  the View and the Controller:communication is “blind” and structured.
The Controller can drop a target on itself.The hand out an action to the View.The View sends the action when things happen in the UI.
Sometimes the View needs to synchronize with the Controller.The Controller sets itself as the View’s delegate.
The delegate is set via a protocol (i.e. It’s ‘blind’ to class).Views do not own the data they display.So,if needed,they have a protocol to acquire it.Controllers are almost always that data source(Not Model!).Controllers interpret/format Model information for the View.
Can the Model talk directly to the Controller?No.The Model is(should be)UI independent.So what if the Model has information to update or something? It uses a “radio station”-like broadcast mechanism.Controllers(or other Model)”tune in” to interesting stuff.View might “tune in”,but probably not to a Model’s “station.”
11.Properties
We use “properties” access instance variables.It just the combination of a getter method and a setter method in a class.The getter (usually) has the name of the property(e.g. “myValue”). The setter’s name is “set” plus capitalized property name(e.g. “setMyValue:”).We just call the setter to store the value we want and the getter to get it.
12.in iOS 7(only),there is special syntax for importing an entire framework called @import. e.g. @import Foundation;It means import all Foundation in the code.
13.strong means:keep the object that this property points to in memory until I set this property to nil(zero).(and it will stay in memory until everyone who has a strong pointer to it sets their property to nil too).
weak mean:if no one else has a strong pointer to this object, then you can  throw it out of memory and set this property to nil(this can happen at any time).
14.Because the compiler takes care of everything you need to implement a property,it’s usually only one line of code(the @property declaration)to add one to your class.
15.Primitive types(int,float,char,BOOL) are not stored in the heap,so there’s no need to specify how the storage for them in the heap is treated.
16.Unless you need to do something besides setting or getting when a property is being set or gotten,the implementation side of this will all happen automatically for you.
17.The syntax of “dot notation“ is only for setters and getters.
18.for(Card *card in otherCards){…}.The for-in looping syntax is called”fast enumeration.”It works on arrays,dictionaries,etc.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值