This thing is flawed, frame? Bring your own MVC? Uiviewcontroller UIView Uinavigationcontroller are these counted? Of course, cocoa Framework, we all know.
In fact, I want to share is: The entire software design code structure management. After reading a lot of sources, summed up the good design code structure distribution logic.
At first, we learned to simply use uibutton,uiimage and other commonly used view classes, we have actually been able to write out the general software. A common feature here is to add a little, there is a network request here, where a bool type is judged, such as common: Isdownding? Reloading?
These, we often in the Viewcontroller directly wrote, so, quickly hit out: @property (nonatomic, assign) BOOL reloading; Then the code, where multiple references are processed.
And if you add a network request, the data is soft, plus a few member variables, Nsarray, nsdictionary, what, and then, more than a few smelly and long regular match something. As you can imagine, this viewcontroller has been very long. Demonstrate:
Well, we started to improve the code, the first step, the basic view independent of a view file storage, separate out. This looks at least 3 points of code, then Viewcontroller, and greatly improve the efficiency of code reading. You can read the whole logic by looking directly at Viewcontroller. And you can do it regardless of the specific implementation.
Then again, we feel that it is not enough, not streamlining. Right. So, we separate the data. independent of abstraction. Create a dedicated object store data object. It can be found that, without exception, all large software will do so. You can also save a lot of code, improve the reading code experience, greatly decoupling the code. These two methods are fairly basic and are basically done. At least the code is readable. Got started. Now the file structure is this:
It looks a lot better.
Well, we've basically formatted the file structure and the basic code distribution problem. However, this is only a primer.
The following are changes based on the complexity requirements of the software:
1. Pull out the part of the network request:
The reasons are as follows: A. Network requests, there will always be error return code, can easily delete and subtract, code easier to find.
B. Network requests, although the network request can be a word, block return processing results, but, based on their own business logic to encapsulate, to a certain extent, reduce the Lotus fit, improve reusability.
C. For a custom Web request, such as a POST request for HTTP, it is necessary to encapsulate the data format independently.
2. Based on the complexity of the data, the corresponding processing, you can add their own business logic of the database processing operations. You can add data classes for a variety of custom types. The benefit of doing this is also to extract the code and reduce the coupling.
Finally upload a summary of the previous, for reference only pictures:
The classification here is really only for reference, the situation is based on the actual project analysis, can not be generalize.
That's all.
iOS Software Development Framework Understanding