接收别人的项目,必定是要增加一些新功能或者优化界面或者修复BUG,好像废话了,说下我的经验吧
场景一:不明飞行物(视图)
视图上没有文字,刚上手的代码不知道哪个viewController,又臭又长的代码不想看,找起来麻烦
解决:
1.在模拟器上command+s,截图,PS上取色,全局搜颜色值,不要一分钟搞定
2.推荐使用Reveal,3D观察你的UI,具体用法百度
场景二:数据复杂
信息类型的app,错综复杂的数据结构让你烦恼,要是没有文档呢,是不是要崩溃了?
解决:
自定义Log,打印出JSON格式的字符串,放在http://www.bejson.com/jsonviewernew/
上面,瞬间理清楚了,我基于别人Foundation+Log.m分类做了修改,希望能帮到你
//
// Foundation+Log.m
// JUJUIM_Demo
//
// Created by maqian on 15/8/31.
// Copyright (c) 2015年 MaQian. All rights reserved.
//
#import <Foundation/Foundation.h>
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *str = [NSMutableString string];
[str appendString:@"{\n"];
// 遍历字典的所有键值对
[self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
NSString *string = [NSString stringWithFormat:@"%@",obj];
if ([string hasPrefix:@"{"] || [string hasPrefix:@"["]) {
[str appendFormat:@"\t\"%@\" : %@,\n", key, obj];
}else{
[str appendFormat:@"\t\"%@\" : \"%@\",\n", key, obj];
}
}];
[str appendString:@"}"];
// 查出最后一个,的范围
NSRange range = [str rangeOfString:@"," options:NSBackwardsSearch];
if (range.length != 0) {
// 删掉最后一个,
[str deleteCharactersInRange:range];
}
return str;
}
@end
@implementation NSArray (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
NSMutableString *str = [NSMutableString string];
[str appendString:@"[\n"];
// 遍历数组的所有元素
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[str appendFormat:@"%@,\n", obj];
}];
[str appendString:@"]"];
// 查出最后一个,的范围
NSRange range = [str rangeOfString:@"," options:NSBackwardsSearch];
if (range.length != 0) {
// 删掉最后一个,
[str deleteCharactersInRange:range];
}
return str;
}
@end
刚想到写这么个文章,有时间在写了,coding...