Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
NetRainMVVMProject
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
NetRainMVVMProject
Commits
d8f1c7cd
Commit
d8f1c7cd
authored
Sep 21, 2020
by
“Icebear”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加YTKNetwork、BaseRequest、多个宏定义文件
parent
efb64673
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
433 additions
and
12 deletions
+433
-12
project.pbxproj
NetrainFrame/NetrainFrame.xcodeproj/project.pbxproj
+92
-12
BaseRequestAPI.h
...inFrame/NetrainFrame/Base/BaseRequestApi/BaseRequestAPI.h
+21
-0
BaseRequestAPI.m
...inFrame/NetrainFrame/Base/BaseRequestApi/BaseRequestAPI.m
+73
-0
FontAndColorMacros.h
NetrainFrame/NetrainFrame/Define/FontAndColorMacros.h
+19
-0
NotificationMacros.h
NetrainFrame/NetrainFrame/Define/NotificationMacros.h
+22
-0
ThirdMacros.h
NetrainFrame/NetrainFrame/Define/ThirdMacros.h
+14
-0
URLMacros.h
NetrainFrame/NetrainFrame/Define/URLMacros.h
+50
-0
UtilsMacros.h
NetrainFrame/NetrainFrame/Define/UtilsMacros.h
+130
-0
Placeholder9
...inFrame/NetrainFrame/Modules/Home/Controller/Placeholder9
+0
-0
Placeholder10
NetrainFrame/NetrainFrame/Modules/Home/Logic/Placeholder10
+0
-0
Placeholder11
NetrainFrame/NetrainFrame/Modules/Home/Model/Placeholder11
+0
-0
Placeholder12
NetrainFrame/NetrainFrame/Modules/Home/Service/Placeholder12
+0
-0
Placeholder13
NetrainFrame/NetrainFrame/Modules/Home/View/Placeholder13
+0
-0
PrefixHeader.pch
NetrainFrame/NetrainFrame/Supporting Files/PrefixHeader.pch
+11
-0
Podfile
NetrainFrame/Podfile
+1
-0
No files found.
NetrainFrame/NetrainFrame.xcodeproj/project.pbxproj
View file @
d8f1c7cd
This diff is collapsed.
Click to expand it.
NetrainFrame/NetrainFrame/Base/BaseRequestApi/BaseRequestAPI.h
0 → 100644
View file @
d8f1c7cd
//
// BaseRequestAPI.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
#import <YTKNetwork/YTKNetwork.h>
/**
接口请求基类,所有请求必须继承此类
这里采用的是YTKNetwork网络库,中大型APP专用,可满足所有网络需求
学习地址:https://github.com/yuantiku/YTKNetwork
*/
@interface
BaseRequestAPI
:
YTKBaseRequest
//自定义属性值
@property
(
nonatomic
,
assign
)
BOOL
isSuccess
;
//是否成功
@property
(
nonatomic
,
copy
)
NSString
*
message
;
//服务器返回的信息
@property
(
nonatomic
,
copy
)
NSDictionary
*
result
;
//服务器返回的数据 已解密
@end
NetrainFrame/NetrainFrame/Base/BaseRequestApi/BaseRequestAPI.m
0 → 100644
View file @
d8f1c7cd
//
// BaseRequestAPI.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
#import "BaseRequestAPI.h"
@implementation
BaseRequestAPI
-
(
instancetype
)
init
{
self
=
[
super
init
];
if
(
self
)
{
}
return
self
;
}
#pragma mark ————— 自定义数据 —————
-
(
NSString
*
)
message
{
if
(
self
.
error
)
{
return
self
.
error
.
localizedDescription
;
}
NSString
*
message
=
[
NSString
stringWithFormat
:
@"%@"
,
self
.
result
[
@"codemsg"
]];
return
message
;
}
-
(
NSString
*
)
code
{
NSString
*
code
=
[
NSString
stringWithFormat
:
@"%@"
,
self
.
result
[
@"code"
]];
return
code
;
}
-
(
BOOL
)
isSuccess
{
NSString
*
code
=
[
self
code
];
BOOL
isSuccess
=
NO
;
if
([
code
isEqualToString
:
@"0"
])
{
isSuccess
=
YES
;
}
return
isSuccess
;
}
#pragma mark ————— 定义返回数据格式,若是加密要用HTTP接受 —————
-
(
YTKResponseSerializerType
)
responseSerializerType
{
return
YTKResponseSerializerTypeJSON
;
}
#pragma mark ————— 默认请求方式 POST —————
-
(
YTKRequestMethod
)
requestMethod
{
return
YTKRequestMethodPOST
;
}
#pragma mark ————— 请求失败过滤器 —————
-
(
void
)
requestFailedFilter
{
//失败处理器
}
#pragma mark ————— 请求成功过滤器 —————
-
(
void
)
requestCompleteFilter
{
self
.
result
=
self
.
responseJSONObject
;
}
#pragma mark ————— 非加密时也要传输的头部内容 也可能不需要,暂时保留 —————
-
(
NSDictionary
<
NSString
*
,
NSString
*>
*
)
requestHeaderFieldValueDictionary
{
//header部分
return
@{};
}
#pragma mark ————— 如果是加密方式传输,自定义request —————
-
(
NSURLRequest
*
)
buildCustomUrlRequest
{
return
nil
;
}
@end
NetrainFrame/NetrainFrame/Define/FontAndColorMacros.h
0 → 100644
View file @
d8f1c7cd
//
// FontAndColorMacros.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
//字体大小和颜色配置
#ifndef FontAndColorMacros_h
#define FontAndColorMacros_h
#pragma mark - 颜色区
#pragma mark - 字号区
#endif
/* FontAndColorMacros_h */
NetrainFrame/NetrainFrame/Define/NotificationMacros.h
0 → 100644
View file @
d8f1c7cd
//
// NotificationMacros.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
//全局标记字符串,用于 通知 存储
#ifndef CommonMacros_h
#define CommonMacros_h
#pragma mark - ——————— 用户相关 ————————
#pragma mark - ——————— 网络状态相关 ————————
//网络状态变化
#define KNotificationNetWorkStateChange @"KNotificationNetWorkStateChange"
#endif
/* CommonMacros_h */
NetrainFrame/NetrainFrame/Define/ThirdMacros.h
0 → 100644
View file @
d8f1c7cd
//
// ThirdMacros.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
//第三方配置
#ifndef ThirdMacros_h
#define ThirdMacros_h
#endif
/* ThirdMacros_h */
NetrainFrame/NetrainFrame/Define/URLMacros.h
0 → 100644
View file @
d8f1c7cd
//
// URLMacros.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
#ifndef URLMacros_h
#define URLMacros_h
/*
将项目中所有的接口写在这里,方便统一管理,降低耦合
这里通过宏定义来切换你当前的服务器类型,
将你要切换的服务器类型宏后面置为真(即>0即可),其余为假(置为0)
如下:现在的状态为测试服务器
这样做切换方便,不用来回每个网络请求修改请求域名,降低出错事件
*/
#define DevelopSever 1
#define TestSever 0
#define ProductSever 0
#if DevelopSever
/**开发服务器*/
#define URL_main @"http://192.168.20.31:20000/shark-miai-service"
//#define URL_main @"http://192.168.11.122:8090" //展鹏
#elif TestSever
/**测试服务器*/
#define URL_main @"http://192.168.20.31:20000/shark-miai-service"
#elif ProductSever
/**生产服务器*/
#define URL_main @"http://192.168.20.31:20000/shark-miai-service"
#endif
#pragma mark - ——————— 详细接口地址 ————————
#pragma mark - ——————— 用户相关 ————————
#endif
/* URLMacros_h */
NetrainFrame/NetrainFrame/Define/UtilsMacros.h
0 → 100644
View file @
d8f1c7cd
//
// URLMacros.h
// NetrainFrame
//
// Created by Gin on 2020/9/21.
//
// 全局工具类宏定义
#ifndef define_h
#define define_h
//获取系统对象
#define kApplication [UIApplication sharedApplication]
#define kAppWindow [UIApplication sharedApplication].delegate.window
#define kAppDelegate [AppDelegate shareAppDelegate]
#define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController
#define kUserDefaults [NSUserDefaults standardUserDefaults]
#define kNotificationCenter [NSNotificationCenter defaultCenter]
#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
#define kNavBarHeight 44.0
#define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)
#define kTopHeight (kStatusBarHeight + kNavBarHeight)
//获取屏幕宽高
#define KScreenWidth ([[UIScreen mainScreen] bounds].size.width)
#define KScreenHeight [[UIScreen mainScreen] bounds].size.height
#define kScreen_Bounds [UIScreen mainScreen].bounds
#define Iphone6ScaleWidth KScreenWidth/375.0
#define Iphone6ScaleHeight KScreenHeight/667.0
//根据ip6的屏幕来拉伸
#define kRealValue(with) ((with)*(KScreenWidth/375.0f))
//强弱引用
#define kWeakSelf(type) __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;
//View 圆角和加边框
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]
// View 圆角
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]
//property 属性快速声明 别用宏定义了,使用代码块+快捷键实现吧
// 当前系统版本
#define CurrentSystemVersion [[UIDevice currentDevice].systemVersion doubleValue]
//当前语言
#define CurrentLanguage ([NSLocale preferredLanguages] objectAtIndex:0])
//-------------------打印日志-------------------------
//DEBUG 模式下打印日志,当前行
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
//拼接字符串
#define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]
//颜色
#define KClearColor [UIColor clearColor]
#define KWhiteColor [UIColor whiteColor]
#define KBlackColor [UIColor blackColor]
#define KGrayColor [UIColor grayColor]
#define KGray2Color [UIColor lightGrayColor]
#define KBlueColor [UIColor blueColor]
#define KRedColor [UIColor redColor]
#define kRandomColor KRGBColor(arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0) //随机色生成
//字体
#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
#define SYSTEMFONT(FONTSIZE) [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME, FONTSIZE) [UIFont fontWithName:(NAME) size:(FONTSIZE)]
//定义UIImage对象
#define ImageWithFile(_pointer) [UIImage imageWithContentsOfFile:([[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@@%dx", _pointer, (int)[UIScreen mainScreen].nativeScale] ofType:@"png"])]
#define IMAGE_NAMED(name) [UIImage imageNamed:name]
//数据验证
#define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
#define SafeStr(f) (StrValid(f) ? f:@"")
#define HasString(str,key) ([str rangeOfString:key].location!=NSNotFound)
#define ValidStr(f) StrValid(f)
#define ValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]])
#define ValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)
#define ValidNum(f) (f!=nil && [f isKindOfClass:[NSNumber class]])
#define ValidClass(f,cls) (f!=nil && [f isKindOfClass:[cls class]])
#define ValidData(f) (f!=nil && [f isKindOfClass:[NSData class]])
//获取一段时间间隔
#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
#define kEndTime NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)
//打印当前方法名
#define ITTDPRINTMETHODNAME() ITTDPRINT(@"%s", __PRETTY_FUNCTION__)
//发送通知
#define KPostNotification(name,obj) [[NSNotificationCenter defaultCenter] postNotificationName:name object:obj];
//单例化一个类
#define SINGLETON_FOR_HEADER(className) \
\
+ (className *)shared##className;
#define SINGLETON_FOR_CLASS(className) \
\
+ (className *)shared##className { \
static className *shared##className = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
shared##className = [[self alloc] init]; \
}); \
return shared##className; \
}
#endif
/* define_h */
NetrainFrame/NetrainFrame/
Base/Placeholder1
→
NetrainFrame/NetrainFrame/
Modules/Home/Controller/Placeholder9
View file @
d8f1c7cd
File moved
NetrainFrame/NetrainFrame/
Define/Placeholder2
→
NetrainFrame/NetrainFrame/
Modules/Home/Logic/Placeholder10
View file @
d8f1c7cd
File moved
NetrainFrame/NetrainFrame/Modules/
Placeholder4
→
NetrainFrame/NetrainFrame/Modules/
Home/Model/Placeholder11
View file @
d8f1c7cd
File moved
NetrainFrame/NetrainFrame/Modules/Home/Service/Placeholder12
0 → 100644
View file @
d8f1c7cd
NetrainFrame/NetrainFrame/Modules/Home/View/Placeholder13
0 → 100644
View file @
d8f1c7cd
NetrainFrame/NetrainFrame/Supporting Files/PrefixHeader.pch
View file @
d8f1c7cd
...
@@ -7,5 +7,16 @@
...
@@ -7,5 +7,16 @@
#ifndef PrefixHeader_pch
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#define PrefixHeader_pch
//全局宏
#import "UtilsMacros.h"
#import "URLMacros.h"
#import "FontAndColorMacros.h"
#import "ThirdMacros.h"
#import "NotificationMacros.h"
//第三方
#import <Masonry.h>
#import <YYModel.h>
#import <SDWebImage/UIImageView+WebCache.h>
#endif /* PrefixHeader_pch */
#endif /* PrefixHeader_pch */
NetrainFrame/Podfile
View file @
d8f1c7cd
...
@@ -9,6 +9,7 @@ pod 'YYModel','1.0.4'
...
@@ -9,6 +9,7 @@ pod 'YYModel','1.0.4'
pod
'SDWebImage'
,
'5.8.4'
pod
'SDWebImage'
,
'5.8.4'
pod
'SVProgressHUD'
,
'2.2.5'
pod
'SVProgressHUD'
,
'2.2.5'
pod
'MJRefresh'
,
'3.4.3'
pod
'MJRefresh'
,
'3.4.3'
pod
'YTKNetwork'
,
'3.0.2'
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment