Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
GMNetService
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMNetService
Commits
d3ecc584
Commit
d3ecc584
authored
Apr 11, 2017
by
licong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加请求前的支持
parent
9202091a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
8 deletions
+21
-8
GMViewController.m
Example/GMNetService/GMViewController.m
+4
-1
Main.storyboard
Example/GMNetService/Main.storyboard
+9
-5
WMNetService.h
GMNetService/Classes/WMNetService.h
+2
-0
WMNetService.m
GMNetService/Classes/WMNetService.m
+6
-2
No files found.
Example/GMNetService/GMViewController.m
View file @
d3ecc584
...
...
@@ -21,7 +21,7 @@
WMNetService
*
service
=
[
WMNetService
sharedInstance
];
service
.
apiHost
=
@"http://backend.gmei.com"
;
NSString
*
path
=
@"/api/index/v3?version=
5.9.5
"
;
NSString
*
path
=
@"/api/index/v3?version=
7.0.0
"
;
service
.
urlCommonParameters
=
@""
;
// 我的需求就是能快速获取几种情况
[[
WMNetService
sharedInstance
]
sendRequestWithURLString
:
path
parameters
:
nil
method
:
HttpMethodGet
success
:^
(
id
responseObject
)
{
...
...
@@ -31,6 +31,9 @@
NSLog
(
@"message"
);
}];
service
.
beforeAction
=
^
{
};
// [[WMNetService sharedInstance] sendRequestWithUrl:path parameters:nil method:HttpMethodGet success:^(NSDictionary *data, NSString *message) {
// NSLog(@"message");
// } failed:^(NSString *message) {
...
...
Example/GMNetService/Main.storyboard
View file @
d3ecc584
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"10117"
systemVersion=
"15F34"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
initialViewController=
"whP-gf-Uak"
>
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"11762"
systemVersion=
"16D32"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
colorMatched=
"YES"
initialViewController=
"whP-gf-Uak"
>
<device
id=
"retina4_7"
orientation=
"portrait"
>
<adaptation
id=
"fullscreen"
/>
</device>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"10085"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"11757"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<scenes>
<!--View Controller-->
...
...
@@ -14,9 +18,9 @@
<viewControllerLayoutGuide
type=
"bottom"
id=
"Mvr-aV-6Um"
/>
</layoutGuides>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"TpU-gO-2f1"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"
600"
height=
"600
"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"
375"
height=
"667
"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"calibratedWhite
"
/>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB
"
/>
</view>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"tc2-Qw-aMS"
userLabel=
"First Responder"
sceneMemberID=
"firstResponder"
/>
...
...
GMNetService/Classes/WMNetService.h
View file @
d3ecc584
...
...
@@ -34,6 +34,8 @@
@property
(
nonatomic
,
strong
)
NSString
*
webHost
;
@property
(
nonatomic
,
strong
)
NSString
*
loginExpiredName
;
@property
(
nonatomic
,
strong
)
NSString
*
urlCommonParameters
;
//请求网络之前调用
@property
(
nonatomic
,
copy
)
void
(
^
beforeAction
)
(
void
);
@property
(
nonatomic
,
copy
)
void
(
^
handleResponse
)
(
NSDictionary
*
response
);
+
(
instancetype
)
sharedInstance
;
...
...
GMNetService/Classes/WMNetService.m
View file @
d3ecc584
...
...
@@ -88,6 +88,9 @@
success
:
(
HttpSuccessBlock
)
success
failed
:
(
HttpFailedBlock
)
failed
{
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
if
(
self
.
beforeAction
)
{
_beforeAction
();
}
if
(
method
==
HttpMethodGet
)
{
[
networking
GET
:
URLString
parameters
:
parameters
success
:^
(
NSURLSessionDataTask
*
task
,
id
responseObject
)
{
[
self
successWithTask
:
task
responseObject
:
responseObject
success
:
success
];
...
...
@@ -156,7 +159,9 @@
}
error
:
nil
];
request
.
timeoutInterval
=
30
;
if
(
self
.
beforeAction
)
{
_beforeAction
();
}
AFURLSessionManager
*
manager
=
[[
AFURLSessionManager
alloc
]
initWithSessionConfiguration
:[
NSURLSessionConfiguration
defaultSessionConfiguration
]];
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
NSURLSessionUploadTask
*
uploadTask
=
[
manager
uploadTaskWithStreamedRequest
:
request
progress
:
NULL
completionHandler
:^
(
NSURLResponse
*
response
,
id
responseObject
,
NSError
*
error
)
{
...
...
@@ -216,7 +221,6 @@
#pragma mark - setter
-
(
void
)
setApiHost
:
(
NSString
*
)
apiHost
{
_apiHost
=
apiHost
;
_networking
=
[
GMHTTPSessionManager
shareInstanceWithApiHost
:
_apiHost
];
}
...
...
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