Skip to content

Commit c533010

Browse files
committed
code style
1 parent 7fa37ad commit c533010

13 files changed

+103
-40
lines changed

NetworkEye.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0A1202451BEC8C9700B710A9 /* UIWindow+NEShakeGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A1202441BEC8C9700B710A9 /* UIWindow+NEShakeGesture.m */; settings = {ASSET_TAGS = (); }; };
10+
0A09FAC01BF6FC3F0009EC53 /* UIWindow+NEExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A09FABF1BF6FC3F0009EC53 /* UIWindow+NEExtension.m */; settings = {ASSET_TAGS = (); }; };
1111
0A1202E31BF097BC00B710A9 /* NEURLSessionConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A1202E21BF097BC00B710A9 /* NEURLSessionConfiguration.m */; settings = {ASSET_TAGS = (); }; };
1212
0A4EF8451BEB66FF000D2D7E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A4EF8441BEB66FF000D2D7E /* main.m */; };
1313
0A4EF8481BEB66FF000D2D7E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A4EF8471BEB66FF000D2D7E /* AppDelegate.m */; };
@@ -46,8 +46,8 @@
4646
/* End PBXContainerItemProxy section */
4747

4848
/* Begin PBXFileReference section */
49-
0A1202431BEC8C9700B710A9 /* UIWindow+NEShakeGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWindow+NEShakeGesture.h"; sourceTree = "<group>"; };
50-
0A1202441BEC8C9700B710A9 /* UIWindow+NEShakeGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWindow+NEShakeGesture.m"; sourceTree = "<group>"; };
49+
0A09FABE1BF6FC3F0009EC53 /* UIWindow+NEExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWindow+NEExtension.h"; sourceTree = "<group>"; };
50+
0A09FABF1BF6FC3F0009EC53 /* UIWindow+NEExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWindow+NEExtension.m"; sourceTree = "<group>"; };
5151
0A1202E11BF097BC00B710A9 /* NEURLSessionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NEURLSessionConfiguration.h; sourceTree = "<group>"; };
5252
0A1202E21BF097BC00B710A9 /* NEURLSessionConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NEURLSessionConfiguration.m; sourceTree = "<group>"; };
5353
0A4EF8401BEB66FF000D2D7E /* NetworkEye.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetworkEye.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -195,8 +195,8 @@
195195
0A4EF8881BEB6735000D2D7E /* NEHTTPModelManager.m */,
196196
0A4EF8891BEB6735000D2D7E /* NEShakeGestureManager.h */,
197197
0A4EF88A1BEB6735000D2D7E /* NEShakeGestureManager.m */,
198-
0A1202431BEC8C9700B710A9 /* UIWindow+NEShakeGesture.h */,
199-
0A1202441BEC8C9700B710A9 /* UIWindow+NEShakeGesture.m */,
198+
0A09FABE1BF6FC3F0009EC53 /* UIWindow+NEExtension.h */,
199+
0A09FABF1BF6FC3F0009EC53 /* UIWindow+NEExtension.m */,
200200
0A1202E11BF097BC00B710A9 /* NEURLSessionConfiguration.h */,
201201
0A1202E21BF097BC00B710A9 /* NEURLSessionConfiguration.m */,
202202
);
@@ -413,7 +413,7 @@
413413
0A4EF8971BEB6735000D2D7E /* NEHTTPEyeViewController.m in Sources */,
414414
0A4EF8991BEB6735000D2D7E /* NEHTTPModelManager.m in Sources */,
415415
0ADE8CFA1BF4999A0096A1E5 /* NEHTTPEyeSettingsViewController.m in Sources */,
416-
0A1202451BEC8C9700B710A9 /* UIWindow+NEShakeGesture.m in Sources */,
416+
0A09FAC01BF6FC3F0009EC53 /* UIWindow+NEExtension.m in Sources */,
417417
);
418418
runOnlyForDeploymentPostprocessing = 0;
419419
};

NetworkEye/NetworkEye/NEHTTPEye.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
#define kSaveRequestMaxCount 300
1313

1414
@interface NEHTTPEye : NSURLProtocol
15+
/**
16+
* open or close HTTP/HTTPS monitor
17+
*
18+
* @param enabled
19+
*/
1520
+ (void)setEnabled:(BOOL)enabled;
21+
22+
/**
23+
* display HTTP/HTTPS monitor state
24+
*
25+
* @return HTTP/HTTPS monitor state
26+
*/
1627
+ (BOOL)isEnabled;
1728
@end

NetworkEye/NetworkEye/NEHTTPEye.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#import "NEHTTPModel.h"
1212
#import "NEHTTPModelManager.h"
13-
#import "UIWindow+NEShakeGesture.h"
13+
#import "UIWindow+NEExtension.h"
1414
#import "NEURLSessionConfiguration.h"
1515
@interface NEHTTPEye ()<NSURLConnectionDelegate, NSURLConnectionDataDelegate>
1616
@property (nonatomic, strong) NSURLConnection *connection;
@@ -22,9 +22,9 @@ @interface NEHTTPEye ()<NSURLConnectionDelegate, NSURLConnectionDataDelegate>
2222

2323
@implementation NEHTTPEye
2424
@synthesize ne_HTTPModel;
25+
#pragma mark - public
2526
+ (void)setEnabled:(BOOL)enabled
2627
{
27-
// BOOL previouslyEnabled =[NEHTTPEye isEnabled];
2828
[[NSUserDefaults standardUserDefaults] setDouble:enabled forKey:@"NetworkEyeEnable"];
2929
[[NSUserDefaults standardUserDefaults] synchronize];
3030
NEURLSessionConfiguration * sessionConfiguration=[NEURLSessionConfiguration defaultConfiguration];
@@ -133,7 +133,7 @@ - (void)stopLoading {
133133
flowCount=flowCount+self.response.expectedContentLength/(1024.0*1024.0);
134134
[[NSUserDefaults standardUserDefaults] setDouble:flowCount forKey:@"flowCount"];
135135
[[NSUserDefaults standardUserDefaults] synchronize];//https://github.com/coderyi/NetworkEye/pull/6
136-
[[NEHTTPModelManager defaultManager] addModel:ne_HTTPModel error:nil];
136+
[[NEHTTPModelManager defaultManager] addModel:ne_HTTPModel];
137137
}
138138

139139
#pragma mark - NSURLConnectionDelegate

NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
@class NEHTTPModel;
1212

1313
@interface NEHTTPEyeDetailViewController : UIViewController
14-
14+
/**
15+
* detail page's data model,about request,response and data
16+
*/
1517
@property (nonatomic,strong) NEHTTPModel *model;
1618

1719
@end

NetworkEye/NetworkEye/NEHTTPEyeSettingsViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
114114

115115
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 9_0){
116116
if(buttonIndex==0){
117-
[[NEHTTPModelManager defaultManager] deleteAllItem:nil];
117+
[[NEHTTPModelManager defaultManager] deleteAllItem];
118118

119119
}
120120
}

NetworkEye/NetworkEye/NEHTTPModelManager.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,43 @@
1515
FMDatabaseQueue *sqliteDatabase;
1616
NSMutableArray *allobjects;
1717
}
18-
18+
/**
19+
* get recorded requests 's SQLite filename
20+
*
21+
* @return filename
22+
*/
1923
+(NSString *)filename;
24+
25+
/**
26+
* get NEHTTPModelManager's singleton object
27+
*
28+
* @return singleton object
29+
*/
2030
+(NEHTTPModelManager *)defaultManager;
31+
32+
/**
33+
* create NEHTTPModel table
34+
*/
2135
+(void)createTable;
22-
-(int)addModel:(NEHTTPModel *) aModel error:(NSError **) error;
36+
37+
38+
/**
39+
* add a NEHTTPModel object to SQLite
40+
*
41+
* @param aModel a NEHTTPModel object
42+
*/
43+
-(void)addModel:(NEHTTPModel *) aModel;
44+
45+
/**
46+
* get SQLite all NEHTTPModel object
47+
*
48+
* @return all NEHTTPModel object
49+
*/
2350
-(NSMutableArray *)allobjects;
24-
- (int) deleteAllItem:(NSError **) error;
51+
52+
/**
53+
* delete all SQLite records
54+
*/
55+
- (void) deleteAllItem;
56+
2557
@end

NetworkEye/NetworkEye/NEHTTPModelManager.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ +(void)createTable{
5151

5252
}
5353

54-
-(int)addModel:(NEHTTPModel *) aModel error:(NSError **) error{
54+
-(void)addModel:(NEHTTPModel *) aModel{
5555

5656
if ([aModel.responseMIMEType isEqualToString:@"text/html"]) {
5757
aModel.receiveJSONData=@"";
5858
}
5959

6060
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"nenetworkhttpeyecache"] isEqualToString:@"a"]) {
61-
[self deleteAllItem:nil];
61+
[self deleteAllItem];
6262
[[NSUserDefaults standardUserDefaults] setObject:@"b" forKey:@"nenetworkhttpeyecache"];
6363
}
6464

@@ -76,7 +76,7 @@ -(int)addModel:(NEHTTPModel *) aModel error:(NSError **) error{
7676
[db executeUpdate:sql];
7777
}];
7878

79-
return 0;
79+
return ;
8080

8181
}
8282

@@ -118,7 +118,7 @@ -(NSMutableArray *)allobjects{
118118

119119
}
120120

121-
- (int) deleteAllItem:(NSError **) error{
121+
- (void) deleteAllItem{
122122

123123
NSString *sql=[NSString stringWithFormat:@"delete from nenetworkhttpeyes"];
124124
FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:[NEHTTPModelManager filename]];
@@ -127,7 +127,7 @@ - (int) deleteAllItem:(NSError **) error{
127127
[db executeUpdate:sql];
128128
}];
129129

130-
return 0;
130+
return ;
131131

132132
}
133133

NetworkEye/NetworkEye/NEShakeGestureManager.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010

1111
@interface NEShakeGestureManager : NSObject
1212

13+
/**
14+
* get NEShakeGestureManager's singleton object
15+
*
16+
* @return singleton object
17+
*/
1318
+(NEShakeGestureManager *)defaultManager;
19+
20+
/**
21+
* show Go NetworkEye page 's alertView
22+
*/
1423
- (void)showAlertView;
1524

1625
@end

NetworkEye/NetworkEye/NEURLSessionConfiguration.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@
99
#import <Foundation/Foundation.h>
1010

1111
@interface NEURLSessionConfiguration : NSObject
12-
@property (nonatomic,assign) BOOL isSwizzle;
12+
@property (nonatomic,assign) BOOL isSwizzle;// whether swizzle NSURLSessionConfiguration's protocolClasses method
13+
14+
/**
15+
* get NEURLSessionConfiguration's singleton object
16+
*
17+
* @return singleton object
18+
*/
1319
+(NEURLSessionConfiguration *)defaultConfiguration;
20+
21+
/**
22+
* swizzle NSURLSessionConfiguration's protocolClasses method
23+
*/
1424
- (void)load;
25+
26+
/**
27+
* make NSURLSessionConfiguration's protocolClasses method is normal
28+
*/
1529
- (void)unload;
1630
@end

NetworkEye/NetworkEye/NEURLSessionConfiguration.m

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,19 @@ - (instancetype)init {
3131
}
3232

3333
- (void)load {
34+
3435
self.isSwizzle=YES;
35-
36-
// static dispatch_once_t onceToken;
37-
// dispatch_once(&onceToken, ^{
38-
// Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
39-
// [self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
40-
// });
4136
Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
4237
[self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
4338

4439
}
4540

4641
- (void)unload {
42+
4743
self.isSwizzle=NO;
48-
4944
Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
5045
[self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
51-
// static dispatch_once_t onceToken;
52-
// dispatch_once(&onceToken, ^{
53-
// Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
54-
// [self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
55-
// });
46+
5647
}
5748

5849
- (void)swizzleSelector:(SEL)selector fromClass:(Class)original toClass:(Class)stub {

0 commit comments

Comments
 (0)