Commit 5e6edb74 authored by 曹云霄's avatar 曹云霄

caoyunxiao

parent 782d4932
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor redColor]; self.view.backgroundColor = [UIColor redColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(100, 100, 100, 100); button.frame = CGRectMake(100, 100, 100, 100);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
......
...@@ -16,7 +16,15 @@ ...@@ -16,7 +16,15 @@
2928F8421CD0ABAC0036D761 /* ShoppingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F8411CD0ABAC0036D761 /* ShoppingViewController.m */; }; 2928F8421CD0ABAC0036D761 /* ShoppingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F8411CD0ABAC0036D761 /* ShoppingViewController.m */; };
2962D06D1CD1A43A0058829D /* ClientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D06C1CD1A43A0058829D /* ClientViewController.m */; }; 2962D06D1CD1A43A0058829D /* ClientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D06C1CD1A43A0058829D /* ClientViewController.m */; };
2962D0711CD1A58B0058829D /* RightViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D0701CD1A58B0058829D /* RightViewController.m */; }; 2962D0711CD1A58B0058829D /* RightViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D0701CD1A58B0058829D /* RightViewController.m */; };
2962D0751CD1AB540058829D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0741CD1AB540058829D /* Images.xcassets */; }; 2962D0791CD1CBC60058829D /* NetworkRequestClassManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D0781CD1CBC60058829D /* NetworkRequestClassManager.m */; };
2962D07D1CD1E4490058829D /* NSArray+Objectwithindex.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D07C1CD1E4490058829D /* NSArray+Objectwithindex.m */; };
2962D0811CD1E6010058829D /* UIView+Frame.m in Sources */ = {isa = PBXBuildFile; fileRef = 2962D0801CD1E6010058829D /* UIView+Frame.m */; };
2962D0881CD1EA350058829D /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0821CD1EA350058829D /* 1.jpg */; };
2962D0891CD1EA350058829D /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0831CD1EA350058829D /* 2.jpg */; };
2962D08A1CD1EA350058829D /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0841CD1EA350058829D /* 3.jpg */; };
2962D08B1CD1EA350058829D /* 4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0851CD1EA350058829D /* 4.jpg */; };
2962D08C1CD1EA350058829D /* 5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0861CD1EA350058829D /* 5.jpg */; };
2962D08D1CD1EA350058829D /* 6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2962D0871CD1EA350058829D /* 6.jpg */; };
29706DA61CD082990003C412 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29706DA51CD082990003C412 /* main.m */; }; 29706DA61CD082990003C412 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29706DA51CD082990003C412 /* main.m */; };
29706DA91CD082990003C412 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 29706DA81CD082990003C412 /* AppDelegate.m */; }; 29706DA91CD082990003C412 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 29706DA81CD082990003C412 /* AppDelegate.m */; };
29706DAF1CD082990003C412 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29706DAD1CD082990003C412 /* Main.storyboard */; }; 29706DAF1CD082990003C412 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29706DAD1CD082990003C412 /* Main.storyboard */; };
...@@ -45,7 +53,18 @@ ...@@ -45,7 +53,18 @@
2962D06C1CD1A43A0058829D /* ClientViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientViewController.m; sourceTree = "<group>"; }; 2962D06C1CD1A43A0058829D /* ClientViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientViewController.m; sourceTree = "<group>"; };
2962D06F1CD1A58B0058829D /* RightViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RightViewController.h; sourceTree = "<group>"; }; 2962D06F1CD1A58B0058829D /* RightViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RightViewController.h; sourceTree = "<group>"; };
2962D0701CD1A58B0058829D /* RightViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RightViewController.m; sourceTree = "<group>"; }; 2962D0701CD1A58B0058829D /* RightViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RightViewController.m; sourceTree = "<group>"; };
2962D0741CD1AB540058829D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; 2962D0771CD1CBC60058829D /* NetworkRequestClassManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkRequestClassManager.h; sourceTree = "<group>"; };
2962D0781CD1CBC60058829D /* NetworkRequestClassManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkRequestClassManager.m; sourceTree = "<group>"; };
2962D07B1CD1E4490058829D /* NSArray+Objectwithindex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Objectwithindex.h"; sourceTree = "<group>"; };
2962D07C1CD1E4490058829D /* NSArray+Objectwithindex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Objectwithindex.m"; sourceTree = "<group>"; };
2962D07F1CD1E6010058829D /* UIView+Frame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Frame.h"; sourceTree = "<group>"; };
2962D0801CD1E6010058829D /* UIView+Frame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Frame.m"; sourceTree = "<group>"; };
2962D0821CD1EA350058829D /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = "<group>"; };
2962D0831CD1EA350058829D /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = "<group>"; };
2962D0841CD1EA350058829D /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 3.jpg; sourceTree = "<group>"; };
2962D0851CD1EA350058829D /* 4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 4.jpg; sourceTree = "<group>"; };
2962D0861CD1EA350058829D /* 5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 5.jpg; sourceTree = "<group>"; };
2962D0871CD1EA350058829D /* 6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 6.jpg; sourceTree = "<group>"; };
29706DA11CD082990003C412 /* Lighting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Lighting.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29706DA11CD082990003C412 /* Lighting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Lighting.app; sourceTree = BUILT_PRODUCTS_DIR; };
29706DA51CD082990003C412 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 29706DA51CD082990003C412 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29706DA71CD082990003C412 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; 29706DA71CD082990003C412 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
...@@ -90,6 +109,15 @@ ...@@ -90,6 +109,15 @@
2928F7DE1CD085430036D761 /* Tools */ = { 2928F7DE1CD085430036D761 /* Tools */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2962D0821CD1EA350058829D /* 1.jpg */,
2962D0831CD1EA350058829D /* 2.jpg */,
2962D0841CD1EA350058829D /* 3.jpg */,
2962D0851CD1EA350058829D /* 4.jpg */,
2962D0861CD1EA350058829D /* 5.jpg */,
2962D0871CD1EA350058829D /* 6.jpg */,
2962D07E1CD1E5DD0058829D /* UIView+Frame */,
2962D07A1CD1E3CC0058829D /* NSarray+category */,
2962D0761CD1CB860058829D /* NetworkRequest */,
2928F8351CD09E500036D761 /* CustomButton */, 2928F8351CD09E500036D761 /* CustomButton */,
2928F7E41CD087C20036D761 /* parentclass */, 2928F7E41CD087C20036D761 /* parentclass */,
2928F7E31CD087B60036D761 /* pch */, 2928F7E31CD087B60036D761 /* pch */,
...@@ -200,6 +228,33 @@ ...@@ -200,6 +228,33 @@
name = RIghtVC; name = RIghtVC;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
2962D0761CD1CB860058829D /* NetworkRequest */ = {
isa = PBXGroup;
children = (
2962D0771CD1CBC60058829D /* NetworkRequestClassManager.h */,
2962D0781CD1CBC60058829D /* NetworkRequestClassManager.m */,
);
name = NetworkRequest;
sourceTree = "<group>";
};
2962D07A1CD1E3CC0058829D /* NSarray+category */ = {
isa = PBXGroup;
children = (
2962D07B1CD1E4490058829D /* NSArray+Objectwithindex.h */,
2962D07C1CD1E4490058829D /* NSArray+Objectwithindex.m */,
);
name = "NSarray+category";
sourceTree = "<group>";
};
2962D07E1CD1E5DD0058829D /* UIView+Frame */ = {
isa = PBXGroup;
children = (
2962D07F1CD1E6010058829D /* UIView+Frame.h */,
2962D0801CD1E6010058829D /* UIView+Frame.m */,
);
name = "UIView+Frame";
sourceTree = "<group>";
};
29706D981CD082980003C412 = { 29706D981CD082980003C412 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -230,7 +285,6 @@ ...@@ -230,7 +285,6 @@
29706DB51CD082990003C412 /* LaunchScreen.storyboard */, 29706DB51CD082990003C412 /* LaunchScreen.storyboard */,
29706DB81CD082990003C412 /* Info.plist */, 29706DB81CD082990003C412 /* Info.plist */,
29706DB01CD082990003C412 /* Lighting.xcdatamodeld */, 29706DB01CD082990003C412 /* Lighting.xcdatamodeld */,
2962D0741CD1AB540058829D /* Images.xcassets */,
29706DA41CD082990003C412 /* Supporting Files */, 29706DA41CD082990003C412 /* Supporting Files */,
); );
path = Lighting; path = Lighting;
...@@ -322,11 +376,16 @@ ...@@ -322,11 +376,16 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
2962D08B1CD1EA350058829D /* 4.jpg in Resources */,
2962D0891CD1EA350058829D /* 2.jpg in Resources */,
29706DB71CD082990003C412 /* LaunchScreen.storyboard in Resources */, 29706DB71CD082990003C412 /* LaunchScreen.storyboard in Resources */,
2962D0751CD1AB540058829D /* Images.xcassets in Resources */, 2962D08C1CD1EA350058829D /* 5.jpg in Resources */,
2962D08D1CD1EA350058829D /* 6.jpg in Resources */,
2928F83D1CD0A9CD0036D761 /* qq.png in Resources */, 2928F83D1CD0A9CD0036D761 /* qq.png in Resources */,
29706DB41CD082990003C412 /* Assets.xcassets in Resources */, 29706DB41CD082990003C412 /* Assets.xcassets in Resources */,
29706DAF1CD082990003C412 /* Main.storyboard in Resources */, 29706DAF1CD082990003C412 /* Main.storyboard in Resources */,
2962D08A1CD1EA350058829D /* 3.jpg in Resources */,
2962D0881CD1EA350058829D /* 1.jpg in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -388,11 +447,14 @@ ...@@ -388,11 +447,14 @@
2928F8381CD09E730036D761 /* CustomButton.m in Sources */, 2928F8381CD09E730036D761 /* CustomButton.m in Sources */,
2928F8421CD0ABAC0036D761 /* ShoppingViewController.m in Sources */, 2928F8421CD0ABAC0036D761 /* ShoppingViewController.m in Sources */,
2928F7E71CD087FE0036D761 /* BaseViewController.m in Sources */, 2928F7E71CD087FE0036D761 /* BaseViewController.m in Sources */,
2962D0791CD1CBC60058829D /* NetworkRequestClassManager.m in Sources */,
2928F8321CD09E320036D761 /* Toolview.m in Sources */, 2928F8321CD09E320036D761 /* Toolview.m in Sources */,
2962D0711CD1A58B0058829D /* RightViewController.m in Sources */, 2962D0711CD1A58B0058829D /* RightViewController.m in Sources */,
29706DA91CD082990003C412 /* AppDelegate.m in Sources */, 29706DA91CD082990003C412 /* AppDelegate.m in Sources */,
29706DA61CD082990003C412 /* main.m in Sources */, 29706DA61CD082990003C412 /* main.m in Sources */,
2962D07D1CD1E4490058829D /* NSArray+Objectwithindex.m in Sources */,
29706DB21CD082990003C412 /* Lighting.xcdatamodeld in Sources */, 29706DB21CD082990003C412 /* Lighting.xcdatamodeld in Sources */,
2962D0811CD1E6010058829D /* UIView+Frame.m in Sources */,
2928F83B1CD0A0CE0036D761 /* CustomTabbarController.m in Sources */, 2928F83B1CD0A0CE0036D761 /* CustomTabbarController.m in Sources */,
2928F8241CD09B2C0036D761 /* LoginViewController.m in Sources */, 2928F8241CD09B2C0036D761 /* LoginViewController.m in Sources */,
2962D06D1CD1A43A0058829D /* ClientViewController.m in Sources */, 2962D06D1CD1A43A0058829D /* ClientViewController.m in Sources */,
......
...@@ -17,6 +17,12 @@ ...@@ -17,6 +17,12 @@
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
/**
* 网络状态
*/
@property (nonatomic,assign) BOOL Networkstatus;
- (void)saveContext; - (void)saveContext;
- (NSURL *)applicationDocumentsDirectory; - (NSURL *)applicationDocumentsDirectory;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
[self SetIQKeyboardManager]; [self SetIQKeyboardManager];
[self RootViewcontroller]; [self RootViewcontroller];
[self detectionNetwork];
return YES; return YES;
} }
...@@ -43,6 +44,43 @@ ...@@ -43,6 +44,43 @@
manager.enableAutoToolbar = YES; manager.enableAutoToolbar = YES;
} }
#pragma mark -检测网络的可连接性
- (void)detectionNetwork
{
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
case AFNetworkReachabilityStatusNotReachable:{
NSLog(@"无网络");
self.Networkstatus = false;
break;
}
case AFNetworkReachabilityStatusReachableViaWiFi:{
NSLog(@"WiFi网络");
self.Networkstatus = true;
break;
}
case AFNetworkReachabilityStatusReachableViaWWAN:{
NSLog(@"流量网络");
self.Networkstatus = true;
break;
}
default:
break;
}
}];
}
- (void)applicationWillResignActive:(UIApplication *)application { - (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "140048947-1.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "140049313-1.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "140049343-1.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "1451383435.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"orientation" : "landscape",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
//
// NSArray+Objectwithindex.h
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSArray (Objectwithindex)
- (id)objectAtIndex_opple:(NSUInteger)index;
@end
//
// NSArray+Objectwithindex.m
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "NSArray+Objectwithindex.h"
@implementation NSArray (Objectwithindex)
- (id)objectAtIndex_opple:(NSUInteger)index;
{
if (index>=self.count) {
return nil;
}
id value = [self objectAtIndex:index];
if (value == [NSNull null]) {
return nil;
}
return value;
}
@end
//
// NetworkRequestClassManager.h
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
//定义返回数据的block类型
typedef void (^ReturnValueBlock) (id returnValue);
typedef void (^ErrorCodeBlock) (id errorCodeValue);
typedef void (^FailureBlock)();
//定义请求类型
typedef enum {
NetworkRequestWithPOST = 0, //POST
NetworkRequestWithGET //GET
}NetworkRequestType;
@interface NetworkRequestClassManager : NSObject
/**
* 网络请求单例
*
* @return NetworkRequestClassManager
*/
+ (NetworkRequestClassManager *)Manager;
/**
* 网络请求
*
* @param requestURLString 网址
* @param requestType 请求类型
* @param parameter 参数
* @param sueecssBlock 成功回调
* @param errorCodeBlock 错误编码回调
* @param failureBlock 失败回调
*/
- (void)NetworkRequestWithURL:(NSString *) requestURLString
WithRequestType:(NetworkRequestType) requestType
WithParameter:(NSDictionary *) parameter
WithReturnValueBlock:(ReturnValueBlock) successBlock
WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
WithFailureBlock:(FailureBlock) failureBlock;
@end
//
// NetworkRequestClassManager.m
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "NetworkRequestClassManager.h"
#import "AppDelegate.h"
@implementation NetworkRequestClassManager
static NetworkRequestClassManager *manager = nil;
/**
* 网络请求单例
*
* @return NetworkRequestClassManager
*/
+ (NetworkRequestClassManager *)Manager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [[NetworkRequestClassManager alloc]init];
});
return manager;
}
+ (id)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager = [super allocWithZone:zone];
});
return manager;
}
/**
* 网络请求
*
* @param requestURLString 网址
* @param requestType 请求类型(POST/GET)
* @param parameter 参数
* @param sueecssBlock 成功回调
* @param errorCodeBlock 错误编码回调
* @param failureBlock 失败回调
*/
- (void)NetworkRequestWithURL:(NSString *) requestURLString
WithRequestType:(NetworkRequestType) requestType
WithParameter:(NSDictionary *) parameter
WithReturnValueBlock:(ReturnValueBlock) successBlock
WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
WithFailureBlock:(FailureBlock) failureBlock
{
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
//网络检测
if (SHARED_APPDELEGATE.Networkstatus == false) {
errorCodeBlock(BROKEN);
return;
}
if (requestType == 0) {
[manager POST:requestURLString parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
successBlock(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
failureBlock(error);
}];
}else if (requestType == 1){
[manager GET:requestURLString parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
successBlock(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
failureBlock(error);
}];
}
}
@end
...@@ -13,12 +13,15 @@ ...@@ -13,12 +13,15 @@
#import "MMDrawerController.h" #import "MMDrawerController.h"
#import "RightViewController.h" #import "RightViewController.h"
#import "IQKeyboardManager.h" #import "IQKeyboardManager.h"
#import "AFNetworking.h"
#import "NetworkRequestClassManager.h"
// Include any system framework and library headers here that should be included in all compilation units. // Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
/** /**
* AppDelegate代理 * AppDelegate代理
*/ */
...@@ -80,6 +83,26 @@ ...@@ -80,6 +83,26 @@
*/ */
#define Zero 0 #define Zero 0
/**
* 断网标示
*/
#define BROKEN @"-1"
......
//
// UIView+Frame.h
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (Frame)
// 分类不能添加成员属性
// @property如果在分类里面,只会自动生成get,set方法的声明,不会生成成员属性,和方法的实现
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
- (void)setMyCorner;
@end
//
// UIView+Frame.m
// Lighting
//
// Created by 曹云霄 on 16/4/28.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "UIView+Frame.h"
@implementation UIView (Frame)
- (void)setX:(CGFloat)x
{
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (CGFloat)x
{
return self.frame.origin.x;
}
- (void)setY:(CGFloat)y
{
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
- (CGFloat)y
{
return self.frame.origin.y;
}
- (CGFloat)width
{
return self.frame.size.width;
}
- (void)setWidth:(CGFloat)width
{
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (CGFloat)height
{
return self.frame.size.height;
}
- (void)setHeight:(CGFloat)height
{
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
- (void)setMyCorner
{
[self.layer setCornerRadius:3.0];
[self.layer setMasksToBounds:YES];
self.layer.shouldRasterize = YES;
self.layer.rasterizationScale = [UIScreen mainScreen].scale;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment