Skip to content

Commit 0b544c7

Browse files
committed
容错性优化
1 parent 8f3198d commit 0b544c7

4 files changed

Lines changed: 56 additions & 19 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
4E6D718D1A762879005AD988 /* icon_user_monkey_i6@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E6D718B1A762879005AD988 /* icon_user_monkey_i6@2x.png */; };
120120
4E6D718E1A762879005AD988 /* icon_user_monkey_i6p@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E6D718C1A762879005AD988 /* icon_user_monkey_i6p@3x.png */; };
121121
4E6FFB311AB3176900F27B3F /* ProjectReadMeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E6FFB301AB3176900F27B3F /* ProjectReadMeCell.m */; };
122+
4E72F82D1B144778001B6CE6 /* NSMutableString+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */; };
122123
4E743E691A8866E300DADDE5 /* taskDescription_add_arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E743E671A8866E300DADDE5 /* taskDescription_add_arrow@2x.png */; };
123124
4E743E6A1A8866E300DADDE5 /* taskDescription_check_arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E743E681A8866E300DADDE5 /* taskDescription_check_arrow@2x.png */; };
124125
4E743E6D1A88A3CC00DADDE5 /* EaseMarkdownTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E743E6C1A88A3CC00DADDE5 /* EaseMarkdownTextView.m */; };
@@ -818,6 +819,8 @@
818819
4E6D718C1A762879005AD988 /* icon_user_monkey_i6p@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_user_monkey_i6p@3x.png"; sourceTree = "<group>"; };
819820
4E6FFB2F1AB3176900F27B3F /* ProjectReadMeCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectReadMeCell.h; sourceTree = "<group>"; };
820821
4E6FFB301AB3176900F27B3F /* ProjectReadMeCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectReadMeCell.m; sourceTree = "<group>"; };
822+
4E72F82B1B144778001B6CE6 /* NSMutableString+Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableString+Common.h"; sourceTree = "<group>"; };
823+
4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableString+Common.m"; sourceTree = "<group>"; };
821824
4E743E671A8866E300DADDE5 /* taskDescription_add_arrow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "taskDescription_add_arrow@2x.png"; sourceTree = "<group>"; };
822825
4E743E681A8866E300DADDE5 /* taskDescription_check_arrow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "taskDescription_check_arrow@2x.png"; sourceTree = "<group>"; };
823826
4E743E6B1A88A3CC00DADDE5 /* EaseMarkdownTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseMarkdownTextView.h; sourceTree = "<group>"; };
@@ -2083,6 +2086,8 @@
20832086
4EE5481D1AE7B7CA00A92306 /* UISearchBar+Common.m */,
20842087
4E969CCE1AF0EB87005C0CCE /* NSTimer+Common.h */,
20852088
4E969CCF1AF0EB87005C0CCE /* NSTimer+Common.m */,
2089+
4E72F82B1B144778001B6CE6 /* NSMutableString+Common.h */,
2090+
4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */,
20862091
);
20872092
path = OC_Category;
20882093
sourceTree = "<group>";
@@ -3751,6 +3756,7 @@
37513756
3A3878371AE293D50078D5DE /* EditLabelViewController.m in Sources */,
37523757
4ECE8AFE1A3946C10021E29C /* Coding_FileManager.m in Sources */,
37533758
4EABD2541AD3CA7E005E515F /* UIMessageInputView.m in Sources */,
3759+
4E72F82D1B144778001B6CE6 /* NSMutableString+Common.m in Sources */,
37543760
4ECE8AE51A3943E80021E29C /* UIImageView+Common.m in Sources */,
37553761
8EF643CA19FF7E2900F7EEB0 /* TopicContentCell.m in Sources */,
37563762
4ECE8AE81A3943E80021E29C /* UIView+Common.m in Sources */,

Coding_iOS/Models/ProjectActivity.m

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "ProjectActivity.h"
10+
#import "NSMutableString+Common.h"
1011

1112
@implementation ProjectActivity
1213
@synthesize actionStr = _actionStr, contentStr = _contentStr;
@@ -74,7 +75,7 @@ - (NSMutableString *)actionStr{
7475
}else if ([_action isEqualToString:@"update_description"]) {
7576
[_actionStr appendFormat:@"更新了任务 [%@] 的描述", _task.title];
7677
}else{
77-
[_actionStr appendString:_action_msg];
78+
[_actionStr saveAppendString:_action_msg];
7879
if (_origin_task.owner) {
7980
[self addActionUser:_origin_task.owner];
8081
[_actionStr appendString:@""];
@@ -91,7 +92,7 @@ - (NSMutableString *)actionStr{
9192
[_actionStr appendFormat:@"%@任务 [%@] 的评论", _action_msg, _task.title];
9293
}else{
9394
[self addActionUser:_user];
94-
[_actionStr appendString:_action_msg];
95+
[_actionStr saveAppendString:_action_msg];
9596
if ([_target_type isEqualToString:@"ProjectTopic"]){
9697
[_actionStr appendString:@"讨论"];
9798
if ([_action isEqualToString:@"comment"]) {
@@ -143,26 +144,26 @@ - (NSMutableString *)contentStr{
143144
}else if ([_action isEqualToString:@"update_deadline"] && _task.deadline && _task.deadline.length > 0) {
144145
[_contentStr appendFormat:@"[%@]", [NSDate convertStr_yyyy_MM_ddToDisplay:_task.deadline]];
145146
}else if ([_action isEqualToString:@"update_description"]) {
146-
[_contentStr appendString:_task.description_mine];
147+
[_contentStr saveAppendString:_task.description_mine];
147148
}else{
148-
[_contentStr appendString:_task.title];
149+
[_contentStr saveAppendString:_task.title];
149150
}
150151
}else if ([_target_type isEqualToString:@"TaskComment"]){
151152
if (_taskComment.content) {
152-
[_contentStr appendString:_taskComment.content];
153+
[_contentStr saveAppendString:_taskComment.content];
153154
}
154155
}else if ([_target_type isEqualToString:@"ProjectTopic"]){
155156
if ([_action isEqualToString:@"comment"]) {
156-
[_contentStr appendString:_project_topic.content];
157+
[_contentStr saveAppendString:_project_topic.content];
157158
}else{
158-
[_contentStr appendString:_project_topic.title];
159+
[_contentStr saveAppendString:_project_topic.title];
159160
}
160161
}else if ([_target_type isEqualToString:@"ProjectFile"]){
161-
[_contentStr appendString:_file.name];
162+
[_contentStr saveAppendString:_file.name];
162163
}else if ([_target_type isEqualToString:@"Depot"]){
163164
if (_commits && [_commits count] > 0) {
164165
Commit *curCommit = _commits.firstObject;
165-
[_contentStr appendString:curCommit.contentStr];
166+
[_contentStr saveAppendString:curCommit.contentStr];
166167
for (int i = 1; i<[_commits count]; i++) {
167168
curCommit = [_commits objectAtIndex:i];
168169
[_contentStr appendFormat:@"\n%@",curCommit.contentStr];
@@ -171,26 +172,26 @@ - (NSMutableString *)contentStr{
171172
}else{
172173
if ([_target_type isEqualToString:@"ProjectMember"]) {
173174
if ([_action isEqualToString:@"quit"]) {
174-
[_contentStr appendString:_project.full_name];
175+
[_contentStr saveAppendString:_project.full_name];
175176
}else{
176-
[_contentStr appendString:_target_user.name];
177+
[_contentStr saveAppendString:_target_user.name];
177178
}
178179
}else if ([_target_type isEqualToString:@"Project"]){
179-
[_contentStr appendString:_project.full_name];
180+
[_contentStr saveAppendString:_project.full_name];
180181
}else if ([_target_type isEqualToString:@"QcTask"]){
181-
[_contentStr appendString:_qc_task.link];
182+
[_contentStr saveAppendString:_qc_task.link];
182183
}else if ([_target_type isEqualToString:@"ProjectStar"]){
183-
[_contentStr appendString:_project.full_name];
184+
[_contentStr saveAppendString:_project.full_name];
184185
}else if ([_target_type isEqualToString:@"ProjectWatcher"]){
185-
[_contentStr appendString:_project.full_name];
186+
[_contentStr saveAppendString:_project.full_name];
186187
}else if ([_target_type isEqualToString:@"PullRequestBean"]){
187-
[_contentStr appendString:_pull_request_title];
188+
[_contentStr saveAppendString:_pull_request_title];
188189
}else if ([_target_type isEqualToString:@"PullRequestComment"]){
189-
[_contentStr appendString:_comment_content];
190+
[_contentStr saveAppendString:_comment_content];
190191
}else if ([_target_type isEqualToString:@"MergeRequestBean"]){
191-
[_contentStr appendString:_merge_request_title];
192+
[_contentStr saveAppendString:_merge_request_title];
192193
}else if ([_target_type isEqualToString:@"MergeRequestComment"]){
193-
[_contentStr appendString:_comment_content];
194+
[_contentStr saveAppendString:_comment_content];
194195
}else if ([_target_type isEqualToString:@"CommitLineNote"]){
195196
[_contentStr appendFormat:@"%@", _line_note.content];
196197
}else{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// NSMutableString+Common.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/26.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface NSMutableString (Common)
12+
- (void)saveAppendString:(NSString *)aString;
13+
@end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// NSMutableString+Common.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/26.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "NSMutableString+Common.h"
10+
11+
@implementation NSMutableString (Common)
12+
- (void)saveAppendString:(NSString *)aString{
13+
if (aString.length > 0) {
14+
[self appendString:aString];
15+
}
16+
}
17+
@end

0 commit comments

Comments
 (0)