iOS Development Learning-lesson two-the structure of the project directory

Source: Internet
Author: User

directory StructureappdelegateModelsMacro GeneralHelpersVendorsSectionsResourcesA reasonable directory structure should first be clear, giving people a glimpse of the responsibilities of the catalog and the ability to respond to new changes. appdelegateThis directory is a AppDelegate.h (. m) file, which is the entry file for the entire application, so take it out separately. ModelsThis directory has a number of data-related model files, presumably:Models|-BaseModel.h|-BASEMODEL.M|-CollectionModel.h|-COLLECTIONMODEL.M    ... MacroThis directory gives the macro definition used by the entire application, presumably:Macro|-AppMacro.h |-NotificationMacro.h |-VendorMacro.h |-UtilsMacro.h ... AppMacro.h App-related macro definitions, such as://Expression-related#define Emotion_cache_path @ "Cachedemotions"#define Emotion_recent_used @ "Recentusedemotions"#define Emotion_categories @ "Categoryemotions"#define Emotion_topics @ "Emotiontopics" //Collection related#define Collect_cache_path @ "collected" //Map related#define WATERFALL_ITEM_HEIGHT_MAX#define WATERFALL_ITEM_WIDTH 146 The NotificationMacro.h is a notification-related macro definition.   In UtilsMacro.h, there are some handy macro definitions, such as:#define UICOLORFROMRGB (r,g,b) [Uicolor \colorwithred:r/255.0 \green:g/255.0 \blue:b/255.0 Alpha:1]#define NSSTRINGFROMINT (intvalue) [NSString stringwithformat:@ "%d", Intvalue] VendorMacro.h Some third-party constants, such as:#define Umeng_key @ "xxxxx"#define UMENG_CHANNEL_ID @ "XXX"If you have a new type of macro definition, you can create a new related Macro.h. GeneralThis directory will be reused by views/classes and categories. It's probably like this: General| -Views|-Tpkscollview|-Tpkpulltorefresh        ...|-Classes|-Tpkbaseviewcontroller|-Tpkhorizontalview        ...|-Categories|-Uiviewcontroller+sizzle|-Uiimageview+downloader... The TPK here is the acronym for the project. HelpersThis directory puts in some helper classes, with filenames linked to functionality. It's probably like this:Helpers|-Tpksharehelper|-Tpdbhelper|-Tpkemotionhelper    ...The main role of helper classes is to help controllers to slim down, but also to provide some degree of reuse. VendorsThis directory puts third-party class libraries/sdk, such as Umeng, WEIBOSDK, WEIXINSDK, and so on. SectionsThe following files in this directory correspond to the specific elements of the app, such as navigation, waterfall flow, and so on. It's probably like this:Sections|-Menu|-Setting|-Collection    ... ResourcesThis directory is a list of resources that the app will use, mostly pictures. CocoapodsBusiness-agnostic class libraries can be conveniently managed through Cocoapods, such as Sdwebimage, reachability, and more. There are also a number of applications will use the basic module, such as Hbapi, Hbsns, Hbfoundation (HB for the company first letter) and so on, you can build a private git repo, and then add to Podfile, so if the Hbapi is updated, only need pod Just update it, please. By the way, hbfoundation, this git repository can put in some of the small modules that all the apps you write are basically going to use. If a lot of apps will jump out of a alertview for a while, you can write a hbrating class, so the app that needs to use this feature simply adds: [Hbrating checkifshouldpopupwithappid: ( Nsinteger) AppID] on the line. Another example is that the app has the need to accept push notification, can write a Hbapns class, and so on. Development ProcessAfter getting the design diagram, you can draw out the reusable classes/views/helpers for the design diagram, consider the specific implementation of an effect, use the appropriate design pattern to avoid a large number of if/else nesting, and so on. Do not drill into the sections in a flash to achieve the page effect and function, it may seem faster at first, but as long as the complexity of the project, this approach will only eat the pain later, the code will become more and more difficult to maintain. So we must do a good job in the preparatory work.

iOS Development Learning-lesson two-the structure of the project directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.