MVC:divide into 3 temp:(Model;View;Controller)
Model:what your application is(but not how it is displayed);
Controller:how your Model is presented to user(UI logic);
View:your Controllers‘ minions(辅助);
CONNECTIONS:
1.Controller can always talk directly to their Model;
2.Controller can always talk directly to their View;(Outlet)
3.The Model and View should never speak to each other;
( the Controller an drop a target on itself,then hand out an action to the View,);
4.the View sends the ACTION when things happen in the UI;
(CONTINUE:the Controller sets itself as the View‘s delegate;The delegate is set via a protocol通过协议委托,but View do not own the data they display;
so, if need, they have a protocol to acquire;Controller are almost always that data source(not model!),
controllers interpret/format Model information for the View;
5.Model talk directly to the Controller?
the Model is UI independent;it use a "radio station" like broadcast mechanism,
Controller (or other Model)"tune in"to interesting stuff;
CLASS TWO:
1.Dash and Plus :
Dash for instance method;
Plus for class method;
6.Instance Variable:
@protected__only the class and subclasses can access;
@private__only the class can access;
@public__anyone can access;
7.anyone can access your instance variable using dot notation:
someObject.eye=newEyeValue; //set the instance variable
int eyeValue=someObject.eye; //get the instance variable‘s current value
8.@property int eye;
equal:-(int)eye:
_(void)setEye:(int)anInt;
9.in .m:
@implemention MyObject;
-(int)eye {
return eye;
}
-(void)setEye:(int)anInt{
eye=anInt;
}
equal:@synthesize eye; or @synthesize eye=p_eye;(get a different variable)
10.All objects that inherit from NSObject know these methods:
isKindOfClass:return whether an object is that kind of class(inheritance include)
isMemberOfClass:returns weather an object is that kind of class (no inheritance)
respondsToSelector:returns weather an object responds to give method
SEL is the Object-C "type" for a selector
SEL shootSelector=@selector(shoot);
SEL moveToSelector=@selector(moveTo:);
Target/action uses this;e.g.:[button addTarget:self action:@selector(digitPressed:)]
explain: IF you have a SEL,you can ask an object to perform it
Using the performSelector :or performSelector:withObject:methods in
NSObject
eg: [obj performSelector:shootSelector];
[obj performSelector:moveToSelector withObject:coordination]
购票解读——5
2023-11-06 22:07:58