Skip to content

Commit e116926

Browse files
committed
Merge pull request #144 from longbai/code_format2
code format
2 parents 74fc116 + 5a4d3e4 commit e116926

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3030
-2987
lines changed

.clang-format

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) 2015-present, Parse, LLC.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree. An additional grant
6+
# of patent rights can be found in the PATENTS file in the same directory.
7+
8+
---
9+
Language: Cpp
10+
BasedOnStyle: LLVM
11+
AccessModifierOffset: -2
12+
AlignAfterOpenBracket: true
13+
AlignEscapedNewlinesLeft: true
14+
AlignOperands: true
15+
AlignTrailingComments: false
16+
AllowAllParametersOfDeclarationOnNextLine: false
17+
AllowShortBlocksOnASingleLine: false
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortIfStatementsOnASingleLine: true
20+
AllowShortLoopsOnASingleLine: false
21+
AllowShortFunctionsOnASingleLine: false
22+
AlwaysBreakAfterDefinitionReturnType: false
23+
AlwaysBreakTemplateDeclarations: false
24+
AlwaysBreakBeforeMultilineStrings: false
25+
BreakBeforeBinaryOperators: None
26+
BreakBeforeTernaryOperators: true
27+
BreakConstructorInitializersBeforeComma: true
28+
BinPackParameters: true
29+
BinPackArguments: true
30+
ColumnLimit: 0
31+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
32+
ConstructorInitializerIndentWidth: 4
33+
DerivePointerAlignment: true
34+
ExperimentalAutoDetectBinPacking: true
35+
IndentCaseLabels: true
36+
IndentWrappedFunctionNames: true
37+
IndentFunctionDeclarationAfterType: true
38+
MaxEmptyLinesToKeep: 1
39+
KeepEmptyLinesAtTheStartOfBlocks: true
40+
NamespaceIndentation: None
41+
ObjCBlockIndentWidth: 4
42+
ObjCSpaceAfterProperty: true
43+
ObjCSpaceBeforeProtocolList: true
44+
PenaltyBreakBeforeFirstCallParameter: 19
45+
PenaltyBreakComment: 300
46+
PenaltyBreakString: 1000
47+
PenaltyBreakFirstLessLess: 140
48+
PenaltyExcessCharacter: 1000000
49+
PenaltyReturnTypeOnItsOwnLine: 120
50+
PointerAlignment: Right
51+
SpacesBeforeTrailingComments: 1
52+
Cpp11BracedListStyle: true
53+
Standard: Cpp11
54+
IndentWidth: 4
55+
TabWidth: 4
56+
UseTab: Never
57+
BreakBeforeBraces: Attach
58+
SpacesInParentheses: false
59+
SpacesInSquareBrackets: false
60+
SpacesInAngles: false
61+
SpaceInEmptyParentheses: false
62+
SpacesInCStyleCastParentheses: false
63+
SpaceAfterCStyleCast: false
64+
SpacesInContainerLiterals: true
65+
SpaceBeforeAssignmentOperators: true
66+
ContinuationIndentWidth: 4
67+
CommentPragmas: '^ IWYU pragma:'
68+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
69+
SpaceBeforeParens: ControlStatements
70+
DisableFormat: false
71+
...

QiniuDemo/QiniuDemo/AppDelegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212

1313
@property (strong, nonatomic) UIWindow *window;
1414

15-
1615
@end
17-

QiniuDemo/QiniuDemo/AppDelegate.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ @interface AppDelegate ()
1414

1515
@implementation AppDelegate
1616

17-
1817
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1918
// Override point for customization after application launch.
2019
return YES;

QiniuDemo/QiniuDemo/ViewController.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
// Copyright © 2016年 Aaron. All rights reserved.
77
//
88

9-
#import <UIKit/UIKit.h>
109
#import <QiniuSDK.h>
10+
#import <UIKit/UIKit.h>
1111

1212
@interface ViewController : UIViewController
1313

14-
@property (nonatomic, weak) IBOutlet UIButton * chooseBtn;
15-
@property (nonatomic, weak) IBOutlet UIButton * uploadBtn;
16-
@property (nonatomic, weak) IBOutlet UIImageView * preViewImage;
14+
@property (nonatomic, weak) IBOutlet UIButton* chooseBtn;
15+
@property (nonatomic, weak) IBOutlet UIButton* uploadBtn;
16+
@property (nonatomic, weak) IBOutlet UIImageView* preViewImage;
1717

1818
@end
19-

QiniuDemo/QiniuDemo/ViewController.m

Lines changed: 58 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#import "AFNetworking.h"
1111
#import "UIImageView+AFNetworking.h"
1212

13-
@interface ViewController ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
13+
@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
1414

15-
@property (nonatomic, strong) NSString * token;
16-
@property (nonatomic, strong) NSString * domain;
17-
@property (nonatomic, strong) UIImage * pickImage;
15+
@property (nonatomic, strong) NSString *token;
16+
@property (nonatomic, strong) NSString *domain;
17+
@property (nonatomic, strong) UIImage *pickImage;
1818

1919
@end
2020

@@ -26,128 +26,115 @@ - (void)viewDidLoad {
2626
self.title = @"七牛云上传";
2727
}
2828

29-
- (IBAction)chooseAction:(id)sender
30-
{
29+
- (IBAction)chooseAction:(id)sender {
3130
[self gotoImageLibrary];
3231
}
3332

34-
- (IBAction)uploadAction:(id)sender
35-
{
33+
- (IBAction)uploadAction:(id)sender {
3634
if (self.pickImage == nil) {
3735
UIAlertView *alert = [[UIAlertView alloc]
38-
initWithTitle:@"还未选择图片"
39-
message:@""
40-
delegate:nil
41-
cancelButtonTitle:@"OK!"
42-
otherButtonTitles:nil];
36+
initWithTitle:@"还未选择图片"
37+
message:@""
38+
delegate:nil
39+
cancelButtonTitle:@"OK!"
40+
otherButtonTitles:nil];
4341
[alert show];
44-
}else
45-
{
46-
[self getTokenFromQN];
42+
} else {
43+
[self getTokenFromQN];
4744
}
4845
}
4946

50-
- (void)getTokenFromQN
51-
{
47+
- (void)getTokenFromQN {
5248
//1.管理器
5349
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
54-
55-
// //2.设置登录参数
56-
// NSDictionary *dict = @{ @"username":@"xn", @"password":@"123" };
57-
50+
51+
// //2.设置登录参数
52+
// NSDictionary *dict = @{ @"username":@"xn", @"password":@"123" };
53+
5854
//3.请求
59-
[manager POST:@"http://115.231.183.102:9090/api/quick_start/simple_image_example_token.php" parameters:nil success: ^(AFHTTPRequestOperation *operation, id responseObject) {
55+
[manager POST:@"http://115.231.183.102:9090/api/quick_start/simple_image_example_token.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
6056
self.domain = responseObject[@"domain"];
6157
self.token = responseObject[@"uptoken"];
6258
[self uploadImageToQNFilePath:[self getImagePath:self.pickImage]];
63-
} failure: ^(AFHTTPRequestOperation *operation, NSError *error) {
64-
NSLog(@"%@", error);
65-
}];
59+
}
60+
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
61+
NSLog(@"%@", error);
62+
}];
6663
}
6764

68-
-(void)uploadImageToQNFilePath:(NSString *)filePath
69-
{
65+
- (void)uploadImageToQNFilePath:(NSString *)filePath {
7066
QNUploadManager *upManager = [[QNUploadManager alloc] init];
71-
QNUploadOption * uploadOption = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) {
72-
NSLog(@"percent == %.2f",percent);
73-
} params:nil checkCrc:NO cancellationSignal:nil];
74-
[upManager putFile:filePath key: nil token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
67+
QNUploadOption *uploadOption = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) {
68+
NSLog(@"percent == %.2f", percent);
69+
}
70+
params:nil
71+
checkCrc:NO
72+
cancellationSignal:nil];
73+
[upManager putFile:filePath key:nil token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
7574
NSLog(@"info ===== %@", info);
7675
NSLog(@"resp ===== %@", resp);
77-
NSLog(@"%@/%@",self.domain,resp[@"key"]);
78-
[self.preViewImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",self.domain,resp[@"key"]]] placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
79-
80-
} option:uploadOption];
81-
82-
}
76+
NSLog(@"%@/%@", self.domain, resp[@"key"]);
77+
[self.preViewImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.domain, resp[@"key"]]] placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
8378

79+
}
80+
option:uploadOption];
81+
}
8482

85-
- (void)gotoImageLibrary
86-
{
87-
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
88-
{
83+
- (void)gotoImageLibrary {
84+
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
8985
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
9086
picker.delegate = self;
9187
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
9288
[self presentViewController:picker animated:YES completion:nil];
93-
}else {
89+
} else {
9490
UIAlertView *alert = [[UIAlertView alloc]
95-
initWithTitle:@"访问图片库错误"
96-
message:@""
97-
delegate:nil
98-
cancelButtonTitle:@"OK!"
99-
otherButtonTitles:nil];
91+
initWithTitle:@"访问图片库错误"
92+
message:@""
93+
delegate:nil
94+
cancelButtonTitle:@"OK!"
95+
otherButtonTitles:nil];
10096
[alert show];
10197
}
10298
}
10399

104-
105-
106100
//再调用以下委托:
107101
#pragma mark UIImagePickerControllerDelegate
108102
- (void)imagePickerController:(UIImagePickerController *)picker
109-
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
110-
{
103+
didFinishPickingImage:(UIImage *)image
104+
editingInfo:(NSDictionary *)editingInfo {
111105
self.pickImage = image; //imageView为自己定义的UIImageView
112106
[picker dismissViewControllerAnimated:YES completion:^{
113107
}];
114-
115-
116108
}
117109

118110
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
119111
[picker dismissViewControllerAnimated:YES completion:nil];
120-
121112
}
122113

123114
//照片获取本地路径转换
124-
-(NSString *)getImagePath:(UIImage *)Image
125-
{
126-
NSString * filePath = nil;
127-
NSData * data = nil;
128-
if (UIImagePNGRepresentation(Image) == nil)
129-
{
115+
- (NSString *)getImagePath:(UIImage *)Image {
116+
NSString *filePath = nil;
117+
NSData *data = nil;
118+
if (UIImagePNGRepresentation(Image) == nil) {
130119
data = UIImageJPEGRepresentation(Image, 1.0);
131-
}
132-
else
133-
{
120+
} else {
134121
data = UIImagePNGRepresentation(Image);
135122
}
136-
123+
137124
//图片保存的路径
138125
//这里将图片放在沙盒的documents文件夹中
139-
NSString * DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
140-
126+
NSString *DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
127+
141128
//文件管理器
142129
NSFileManager *fileManager = [NSFileManager defaultManager];
143-
130+
144131
//把刚刚图片转换的data对象拷贝至沙盒中
145132
[fileManager createDirectoryAtPath:DocumentsPath withIntermediateDirectories:YES attributes:nil error:nil];
146-
NSString * ImagePath = [[NSString alloc]initWithFormat:@"/theFirstImage.png"];
133+
NSString *ImagePath = [[NSString alloc] initWithFormat:@"/theFirstImage.png"];
147134
[fileManager createFileAtPath:[DocumentsPath stringByAppendingString:ImagePath] contents:data attributes:nil];
148-
135+
149136
//得到选择后沙盒中图片的完整路径
150-
filePath = [[NSString alloc]initWithFormat:@"%@%@",DocumentsPath,ImagePath];
137+
filePath = [[NSString alloc] initWithFormat:@"%@%@", DocumentsPath, ImagePath];
151138
return filePath;
152139
}
153140

QiniuDemo/QiniuDemo/main.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
// Copyright © 2016年 Aaron. All rights reserved.
77
//
88

9-
#import <UIKit/UIKit.h>
109
#import "AppDelegate.h"
10+
#import <UIKit/UIKit.h>
1111

12-
int main(int argc, char * argv[]) {
12+
int main(int argc, char* argv[]) {
1313
@autoreleasepool {
1414
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
1515
}

QiniuDemo/QiniuDemoUITests/QiniuDemoUITests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ @implementation QiniuDemoUITests
1616

1717
- (void)setUp {
1818
[super setUp];
19-
19+
2020
// Put setup code here. This method is called before the invocation of each test method in the class.
21-
21+
2222
// In UI tests it is usually best to stop immediately when a failure occurs.
2323
self.continueAfterFailure = NO;
2424
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
2525
[[[XCUIApplication alloc] init] launch];
26-
26+
2727
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
2828
}
2929

0 commit comments

Comments
 (0)