Directory structure for iOS development

Source: Internet
Author: User

http://www.itjhwd.com/iosmolukaifa/

Directory structure

Personal Summary: =================================================================================================

Models
Sections
Module1
Views
Module2
Views
Generals
Views
Classes

Categories

Macros

Helpers
Vendors
Resources

=================================================================================================objective-c
12345678 appdelegate Models Macro General Helpers Vendors Sections Resources

A 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.

Appdelegate

This directory is a AppDelegate.h (. m) file, which is the entry file for the entire application, so take it out separately.

Models

This directory has a number of data-related model files, presumably:

objective-c
123456 Models| - basemodel. H | - basemodel. M | - collectionmodel. H | - collectionmodel. M . . .

Macro

This directory gives the macro definition used by the entire application, presumably:

objective-c
123456 Macro| - appmacro. H | - notificationmacro. H | - vendormacro. H | - utilsmacro. H . . .

AppMacro.h app-related macro definitions, such as:

objective-c
123456789101112 //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:

objective-c
123456 #define UICOLORFROMRGB (r,g,b) [Uicolor \ colorwithred:r/255.0 \ green:g/255.0< Span class= "crayon-h" > \ blue:b/255.0 alpha:1   #define NSSTRINGFROMINT (intvalue) [NSString stringwithformat:@ "%d", Intvalue]

VendorMacro.h Some third-party constants, such as:

objective-c
12 #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.

General

This directory will be reused by views/classes and categories. It's probably like this:

objective-c
12345678910111213 General | - views| - tpkscollview | - tpkpulltorefresh . . .| - Classes | - tpkbaseviewcontroller | - tpkhorizontalview . . .| - Categories | - uiviewcontroller+Sizzle | - uiimageview+Downloader . . .

The TPK here is the acronym for the project.

Helpers

This directory puts in some helper classes, with filenames linked to functionality. It's probably like this:

objective-c
12345 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.

Vendors

This directory puts third-party class libraries/sdk, such as Umeng, WEIBOSDK, WEIXINSDK, and so on.

Sections

The 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:

objective-c
12345 Sections |    - Menu |    - Setting |    - Collection . . .

Resources

This directory is a list of resources that the app will use, mostly pictures.

Cocoapods

Business-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 process

After 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.

Experience is limited, if you have a better idea, welcome to exchange:)

Original source: Limboy

Directory structure for iOS development

Related Article

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.