IOS 文件夹结构

版权声明:本文为博主原创文章,未经博主同意不得转载。

https://blog.csdn.net/MyGameZone/article/details/24494765

IOS文件夹结构

说明

这些仅仅是个人的总结,仅供參考,有什么不足的地方请指出,大家一起进步。

文件夹结构组成

一般来说,文件夹结构能够由下面几个子文件夹组成:

|- AppDelegate|- Macro
|- Models
|- Geneal

|- Hepers
|- Vendors|- Resources

AppDelegate

这个文件夹下放的是 AppDelegate.hAppDelegate.m,由于它们是整个App 的入口,所以这个文件夹下一般就包括2 个文件。
AppDelegate

|- AppDelegate.h|- AppDelegate.m

Macro

这个文件夹下放的是整个 App会用到的宏。宏的用途也分为好几种,如作为常量,作为消息,作为函数。

Macro

  • |-  ConstantMacro.h

  • |-  MessageMacro.h

  • |-  VendorMacro.h

  • |-  ImageNameMacro.h

  • |-  UtilityMacro.h

    ...

//常量
#define PERSON_NUM 10
//
消息
#define USER_MESSAGE_COLLECTION @”user_message_collection”
//
第三方 AppKey
#define WEIXIN_KEY @”xxxxxxxx”
//
有用宏
#define RGBColor(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]//图片名字
#define HOME_LOGO @”logo.png”

Models

这个文件夹下放的是和数据相关的 Model 文件Models

  • |-  PersonModel.h

  • |-  PersonModel.m

  • |-  HotelModel.h

  • |-  HotelModel.m...

    //PersonModel.h
    @class IdCard;
    @interface PersonModel : NSObject
    @property (nonatomic, strong) NSString * name;@property (nonatomic, strong) NSNumber * age;@property (nonatomic, strong) IdCard *idCard;@end

    Geneal

    这个文件夹下放的是一些 Views/Controllers/Categories等,这样划分层次更加清晰,个人建议还是依照树形结构来划分,这样某个模块出现错误能够高速定位。
    General

    |- Views
    |- HomeView

    |- AdView

    ...
    |- DetailsView

    ...
    |- Controllers

|- HomeViewController|- DetailsViewController...

|- Categories
|- UIImageView+Downloader|- UIView+Sizzle
...

Hepers

这个文件夹下放的是一些助手性的文件,如计算经纬度、坐标转换、数据库管理,这些一般都是些通用的类或者函数。
Hepers

|- DatabaseHeper|- ClientHeper
|- FileHelper
...

//ClientHeper.h
@interface ClientHeper : NSObject

+ (ClientHeper *) sharedClient;
- (void)setDefaultCachePath:(NSString *)path;- (NSString *)defaultCacheSize;
- (void)cleanDefaultCache;

Vendors

这个文件夹下放的是一些第三方类库,如 WeiXinSDK,WeiBoSDK,ASIVendors

|- WeiXinSDK|- WeiBoSDK|- ASIHttp
...

Resources

这个文件夹下放的是图片、声音、文本等资源。

Resources

  • |-  Images

  • |-  Sounds

  • |-  Databases

  • |-  Html...

    最后

    唯一不变的就是变化,代码的规范化上没有什么对或者不正确,仅仅是统一的规范能够提高团队合作效率。我在这里附上google 的代码规范,希望大家能够一起进步,祝好运。 

  • PDF下载地址

  • Google C代码规范

【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/ldxsuanfa/p/10613357.html