-(void) landAPP:(NSString *)phoneNo passWord:(NSString *)password version:(NSString *)version model:(NSString *)model
{
NSDictionary *parameter = @{PHONENO :phoneNo ,
PASSWORD:password,
VERSION:version,
MODEL:model
};
[NetRequestClass NetRequestGETWithRequestURL:URL_LOGIN WithParameter:parameter WithReturnValeuBlock:^(id returnValue) {
//处理请求数据
} WithErrorCodeBlock:^(id errorCode) {
DDLog(@"%@", errorCode);
[self errorCodeWithDic:errorCode];
} WithFailureBlock:^{
[self netFailure];
DDLog(@"网络异常");
}];
}
2. viewController:存放ViewController类资源文件,也就是View层
LandViewModel *publicViewModel = [[LandViewModel alloc] init];
[publicViewModel setBlockWithReturnBlock:^(id returnValue) {
//view层处理
[SVProgressHUD dismiss];
} WithErrorBlock:^(id errorCode) {
[SVProgressHUD dismiss];
} WithFailureBlock:^{
[SVProgressHUD dismiss];
}];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
NSString *model=[[UIDevice currentDevice] model];
[publicViewModel landApp:phonNo passWord:pass version:version model:model];
[SVProgressHUD showWithStatus:@"正在登录……" maskType:SVProgressHUDMaskTypeBlack];
3. model:存放你的get和set属性
@interface PublicModel : NSObject
@property (strong, nonatomic) NSString *age;
@property (strong, nonatomic) NSString *sex;
4. config:工程配置文件
pch文件
你可以建立自己的.h文件放置你的配置文件 如:
#ifndef Prj_Config_h
#define Prj_Config_h
//请求公共微博的网络接口
#define REQUESTPUBLICURL @"https://api.weibo.com/2/statuses/public_timeline.json”
#define PHONENO @"phoneNo"
#define PASSWORD @"passWord"
#define VERSION @“version"
#endif
5. vendor:就不用说了,第三方库
6.Resource:就是工程的资源文件,下面有图片资源和Storyboard文件资源
二:项目中单例模式使用
许多开发者常常缺少对单例模式的使用,如请求为了避免实例多次被创建:
#import "ServiceManager.h"
@implementation ServiceManager
+(ServiceManager*)shareInstance{
static ServiceManager *manager = nil;
if (!manager) {
manager = [[ServiceManager alloc] init];
}
return manager;
}
- (id)init
{
if(self = [super init])
{
[self initManagers];
}
return self;
}
-(void)initManagers{
_fSearchService = [[FDSearchService alloc] init];
}
#import "FDSearchService.h"
#pragma mark -搜索
-(void)registDownloadFoundationList:(NSDictionary *)dic dependCtr:(UIViewController*)ctr{
NetworkRequestModel *model = [[NetworkRequestModel alloc] initDependController:ctr];
model.target = self;
model.type = requestDownloadFoundationList;
model.method = POST;
model.parameters = dic;
model.selector = @selector(responseDownloadFoundationList:networkModel:);
[[HttpRequestManager sharedManager] requestDataWithModel:model];
}
@end
三:注意规范事项
1. 许多开发者在xcode工程中new group,只是在视觉效果上分好了几个文件夹,方便分类管理,但在finder中并不会创建新的文件夹。
正确方式:在finder找到把工程,新建文件夹,这样方便代码维护。