This chapter guides you through the process of finding the best architecture for your project.
There’s no shortage of architecture patterns. Unfortunately, most patterns only scratch the surface and leave you to figure out the fine details. In addition, many patterns are similar to one another and have only minor differences here and there.
There are pragmatic steps you can take to ensure your architecture is effective:
Understand the current state of your codebase.
Identify problems you’d like to solve or code you’d like to improve.
Evaluate different architecture patterns.
Try a couple patterns on for size before committing to one.
Draw a line in the sand and define your app’s baseline architecture.
Look back and determine if your architecture is effectively addressing the problems you want to solve.
Iterate and evolve your app’s architecture over time.
/** * Sends a message with a simple return value to the superclass of an instance of a class. * * @param super A pointer to an \c objc_super data structure. Pass values identifying the * context the message was sent to, including the instance of the class that is to receive the * message and the superclass at which to start searching for the method implementation. * @param op A pointer of type SEL. Pass the selector of the method that will handle the message. * @param ... * A variable argument list containing the arguments to the method. * * @return The return value of the method identified by \e op. * * @see objc_msgSend */ id objc_msgSendSuper(struct objc_super *super, SEL op, ...) struct objc_super2 { id receiver; //消息接收者 Class cls; // the class to search,消息接收者的父类 }
获取方法的相关信息(带有copy的需要调用free去释放) SEL method_getName(Method m) IMP method_getImplementation(Method m) const char *method_getTypeEncoding(Method m) unsigned int method_getNumberOfArguments(Method m) char *method_copyReturnType(Method m) char *method_copyArgumentType(Method m, unsigned int index)
选择器相关 const char *sel_getName(SEL sel) SEL sel_registerName(const char *str)
用block作为方法实现 IMP imp_implementationWithBlock(id block) id imp_getBlock(IMP anImp) BOOL imp_removeBlock(IMP anImp)