格纸 隐私协议

欢迎使用 格纸.

格纸(以下简称“我们”)制定本隐私政策(以下简称“本政策”),来解释我们如何收集、保存使用由我们的产品、服务和网站(以下合称“我们的服务”)收集的信息。

我们是一款单机游戏, 仅对APP的奔溃信息进行搜集, 我们使用的收集工具为Bugtags, 相关隐私协议详见: https://docs.bugtags.com/zh/bugtags/terms.html.

如果您有任何问题, 请联系我们.
手机: 17689214697
邮件: xinmuheart@gmail.com
微信: GuanQuanHua

解压数数 隐私协议

欢迎使用 “解压数数”.

解压数数(以下简称“我们”)制定本隐私政策(以下简称“本政策”),来解释我们如何收集、保存使用由我们的产品、服务和网站(以下合称“我们的服务”)收集的信息。

我们是一款单机游戏, 仅对APP的奔溃信息进行搜集, 我们使用的收集工具为Bugtags, 相关隐私协议详见: https://docs.bugtags.com/zh/bugtags/terms.html.

如果您有任何问题, 请联系我们.
手机: 17689214697
邮件: xinmuheart@gmail.com
微信: GuanQuanHua

Blur HQ 隐私协议

欢迎使用 Blur HQ.

Blur HQ(以下简称“我们”)制定本隐私政策(以下简称“本政策”),来解释我们如何收集、保存使用由我们的产品、服务和网站(以下合称“我们的服务”)收集的信息。

我们是一款单机游戏, 仅对APP的奔溃信息进行搜集, 我们使用的收集工具为Bugtags, 相关隐私协议详见: https://docs.bugtags.com/zh/bugtags/terms.html.

如果您有任何问题, 请联系我们.
手机: 17689214697
邮件: xinmuheart@gmail.com
微信: GuanQuanHua

38=64 隐私协议

欢迎使用 38=64.

38=64(以下简称“我们”)制定本隐私政策(以下简称“本政策”),来解释我们如何收集、保存使用由我们的产品、服务和网站(以下合称“我们的服务”)收集的信息。

我们是一款单机游戏, 仅对APP的奔溃信息进行搜集, 我们使用的收集工具为Bugtags, 相关隐私协议详见: https://docs.bugtags.com/zh/bugtags/terms.html.

如果您有任何问题, 请联系我们.
手机: 17689214697
邮件: xinmuheart@gmail.com
微信: GuanQuanHua

iOS笔记

GETs

(20151203)
45. 所有和相册,相机相关的操作, 需要注意是否有相应的权限.

(20160727)
46.
提交: A->B->C(Current, 当前位置)

执行
git reset --hard (B的Commit ID) 回到B提交点.

之后, 可以试试 git reflog, 尝试找回C提交点的Commit ID.

(20160803)
47. 设置UIButton的标题和图片, 将图片显示在右边.
- (void)setupTitleViewWithAlbum:(MYAssetsAlbum *)album
{
NSString *title = album ? album.name : @"照片";
self.titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.titleButton setTitle:title forState:UIControlStateNormal];
[self.titleButton setImage:[UIImage imageNamed:@"album_arrow"] forState:UIControlStateNormal];
[self.titleButton setTitleColor:DEFAULT_RED_BUTTON_COLOR forState:UIControlStateNormal];
[self.titleButton addTarget:self action:@selector(titleButtonTapAction:) forControlEvents:UIControlEventTouchUpInside];
self.titleButton.titleLabel.font = [UIFont systemFontOfSize:15.0f];
CGSize textSize = [title sizeWithAttributes:@{NSFontAttributeName:self.titleButton.titleLabel.font}];
CGFloat space = 5.0f;
self.titleButton.imageEdgeInsets = UIEdgeInsetsMake(0, textSize.width+space, 0, -space);
self.titleButton.titleEdgeInsets = UIEdgeInsetsMake(0, -self.titleButton.imageView.image.size.width, 0, self.titleButton.imageView.image.size.width);
[self.titleButton sizeToFit];
self.customNavItem.titleView = self.titleButton;
}

(20160804)
48.获得两个版本间所有变更的文件列表 git diff –name-status HEAD~2 HEAD~3
49. 关于AutoLayout的优先级
– static const UILayoutPriority UILayoutPriorityRequired NS_AVAILABLE_IOS(6_0) = 1000; // A required constraint. Do not exceed this.
– static const UILayoutPriority UILayoutPriorityDefaultHigh NS_AVAILABLE_IOS(6_0) = 750; // This is the priority level with which a button resists compressing its content.
– static const UILayoutPriority UILayoutPriorityDefaultLow NS_AVAILABLE_IOS(6_0) = 250; // This is the priority level at which a button hugs its contents horizontally.
– static const UILayoutPriority UILayoutPriorityFittingSizeLevel NS_AVAILABLE_IOS(6_0) = 50; // When you send -[UIView systemLayoutSizeFittingSize:], the size fitting most closely to the target size (the argument) is computed.
-总结下就是Required最高、然后是High,然后是Low

50. 设置IULabel的shadowColor和shadowOffset.
btn.titleLabel.layer.shadowOpacity = 1.0f;
btn.titleLabel.shadowColor = COLOR_RGB(0x999999, 1.0);
btn.titleLabel.shadowOffset = CGSizeZero;

(20160805)
51. Command+(上/下箭头): 进入文件夹,打开文件/返回上级文件夹; Command+([/]): 文件夹后退/前进.

(20160809)
52. git checkout -b new_branch : create and checkout the new_branch

53. UIMenuController *menu = [UIMenuController sharedMenuController];

(2016/08/10)
54. 关于UITableView刷新某些行;

// Row insertion/deletion/reloading.

– (void)beginUpdates; // allow multiple insert/delete of rows and sections to be animated simultaneously. Nestable
– (void)endUpdates; // only call insert/delete/reload calls or change the editing state inside an update block. otherwise things like row count, etc. may be invalid.

//////////
// 以下函数最好包在beginUpdates和endUpdates之间执行, 否则可能造成奔溃(attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update).
//////////

– (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
– (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
– (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);
– (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection NS_AVAILABLE_IOS(5_0);

– (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
– (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
– (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);
– (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath NS_AVAILABLE_IOS(5_0);

54.1 关于UITableView刷新cell.
– reloadRowsAtIndexPaths:withRowAnimation:
Reloads the specified rows using an animation effect.

[[Discussion]]
Reloading a row causes the table view to ask its data source for a new cell for that row. The table animates that new cell in as it animates the old row out. Call this method if you want to alert the user that the value of a cell is changing. If, however, notifying the user is not important—that is, you just want to change the value that a cell is displaying—you can get the cell for a particular row and set its new value.

When this method is called in an animation block defined by the beginUpdates and endUpdates methods, it behaves similarly to deleteRowsAtIndexPaths:withRowAnimation:. The indexes that UITableView passes to the method are specified in the state of the table view prior to any updates. This happens regardless of ordering of the insertion, deletion, and reloading method calls within the animation block.

55. 调用别人的代码一定要弄清楚代码什么情况下会返回, 是否一定会执行某个操作? 完整细心.

(2016/08/11)

56.git stash
git stash show
git stash clear

57.view的tag要统一管理, 以防冲突; 最好别用;

(2016/08/15)
58.UITableView注册Cell,Header,Footer.
[self registerNib:[UINib nibWithNibName:@”MYTutorialCommentCell” bundle:nil] forCellReuseIdentifier:kGoodCommentCellIdentifier];
[self registerClass:[MYCommentHeader class] forHeaderFooterViewReuseIdentifier:kCommentHeaderIdentifier];
[self registerClass:[MYCommentFooter class] forHeaderFooterViewReuseIdentifier:kCommentFooterIdentifier];

(2016/08/15)
59. 一般情况下,键盘最适合放在keywindow上;
[[UIApplication sharedApplication].keyWindow addSubview:self.commentViewModel.inputTool];

60. sublime 正则替换 (.*)->@”$1″

61. 被除数一定不可以为0;

62. thread 调试时返回(return);

(2016/08/16)

63. 各种用户输入内容的操作前要检查是否登录.
[[UserManager shareInstance] checkAndTryLoginWithReuslt:^void (BOOL bSuccess) {
[weakSelf.commentViewModel.inputTool showKeyboardPanel];
weakSelf.commentViewModel.inputTool.hidden = NO;
}];

(20160819)
64. 注意用户输入内容的敏感词过滤操作.

(20160825)
65. CoreText string attributes

+ (NSDictionary *)commonAttributes {
static NSDictionary *commonAttributes;

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CTFontRef fontRef = [UIFont systemFontOfSize:12].CTFont;
// 换行模式
CTParagraphStyleSetting lineBreakMode;
CTLineBreakMode lineBreak = kCTLineBreakByTruncatingTail;
lineBreakMode.spec = kCTParagraphStyleSpecifierLineBreakMode;
lineBreakMode.value = &lineBreak;
lineBreakMode.valueSize = sizeof(CTLineBreakMode);
// 行间距
CTParagraphStyleSetting lineSpacing;
CGFloat spacing = 5.0f;
lineSpacing.spec = kCTParagraphStyleSpecifierLineSpacingAdjustment;
lineSpacing.value = &spacing;
lineSpacing.valueSize = sizeof(CGFloat);

CTParagraphStyleSetting settings[] = {lineBreakMode, lineSpacing};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, 2);

commonAttributes = @{(__bridge id)kCTForegroundColorAttributeName : (__bridge id)RGBCOLOR(51, 51, 51).CGColor,
(__bridge id)kCTFontAttributeName : (__bridge id)fontRef,
(__bridge id)kCTParagraphStyleAttributeName : (__bridge id)paragraphStyle,
};
});

return commonAttributes;
}

(20160909)
66. objc_setAssociatedObject(self, &ObjectKey, object, OBJC_ASSOCIATION_ASSIGN);

/* Associative References */

/**
* Policies related to associative references.
* These are options to objc_setAssociatedObject()
*/
typedef OBJC_ENUM(uintptr_t, objc_AssociationPolicy) {
OBJC_ASSOCIATION_ASSIGN = 0, /**< Specifies a weak reference to the associated object. */
OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, /**< Specifies a strong reference to the associated object.
* The association is not made atomically. */
OBJC_ASSOCIATION_COPY_NONATOMIC = 3, /**< Specifies that the associated object is copied.
* The association is not made atomically. */
OBJC_ASSOCIATION_RETAIN = 01401, /**< Specifies a strong reference to the associated object.
* The association is made atomically. */
OBJC_ASSOCIATION_COPY = 01403 /**< Specifies that the associated object is copied. * The association is made atomically. */ }; (20160913) 67. __attribute__((deprecated)) 可以使用 deprecated 变量属性声明不提倡使用的变量,而不会导致编译器发出任何警告或错误。但是,对 deprecated 变量的任何访问都会生成警告,但仍会进行编译。警告指出了使用和定义变量的位置。这有助于确定不提倡使用特定定义的原因。 68. gco – => git checkout – => git checkout @{-1} => git checkout @{-n}

69. 自定义警告信息 #define LETS_DEPRECATED(message) __attribute__((deprecated(message)))

70. dispatch_apply, 并行处理不会相互影响的集合数据;

(20160914)
71. UITableView和UICollectionView的datasource一旦修改, 应该马上去刷新(reloadData);

72. 通过并行队列实现同步:(需要自己创建并发队列)
dispatch_barrier_async, 如果传入自己创建的并行队列时,会阻塞当前队列执行,而不阻塞当前线程。
dispatch_barrier_sync, 如果传入自己创建的并行队列时,阻塞当前队列的同时也会阻塞当前线程,请注意

并发队列如果发现接下来要处理的块是个栅栏块,那么就一直要等当前所有并发块都执行完毕,才会单独执行这个栅栏块。这待栅栏块执行完毕,在按正常方式继续向下处理。这样就解决了并发队列的同步问题。

(20160920)
73. sudo gem install cocoapods -v 0.39.0

74. 在命令行中翻墙
想临时走的话(只当前窗口有效),
export {http,https,ftp}_proxy=’http://127.0.0.1:8087′
想一直有的话,写到 rc 文件里去, bashrc or zshrc

(20160922)
75. git push –set-upstream origin current_branch_name
gpp=’git push -u origin $(git name-rev –name-only HEAD)’

76. [self.view layoutIfNeeded] 与 导航栏左右两边的item位置错位(iOS 10) 相关;

(20160928)
77.
Swizzling should always be done in +load.
Swizzling should always be done in a dispatch_once.

78. Always endeavor to replace magical thinking with understanding.

(20160929)
79.
defaults write com.apple.Finder AppleShowAllFiles YES

(20160930)
80.
git checkout HEAD~2

(20161009)
81. UIGraphicsBeginImageContext;UIGraphicsEndImageContext; 请成对出现.否则会造成内存泄露滴!!!

(20161012)
82. 总结:Linux和其它代码库里的宏都用do/while(0)来包围执行逻辑,因为它能确保宏的行为总是相同的,而不管在调用代码中使用了多少分号和大括号。

(20161013)
83. 关于宏定义中的”#”(字符串化)和”##”(字符串连接)
e.g.

#import <Foundation/Foundation.h>
#define tokenpaster(n) NSLog (@”token” #n ” = %d”, token##n)

int main(void) {
int token34 = 40;
tokenpaster(34);
return 0;
}

输出结果:(When the above code is compiled and executed, it produces the following result):
2013-09-14 05:48:14.859 demo[20683] token34 = 40

84. 参数化宏 e.g. #define MAX(x,y) ((x) > (y) ? (x) : (y))

85. CALayer防止显示模糊 (做动画时)
self.contentsScale = kScreenScale;
self.shouldRasterize = YES;
self.rasterizationScale = kScreenScale;

86. 总共n个, 每行显示m个, n > 0 && m > 0, 一共: ((n – 1) / m) 行;

(20161019)
87. CGContextDrawLinearGradient(<#CGContextRef _Nullable c#>, <#CGGradientRef _Nullable gradient#>, <#CGPoint startPoint#>, <#CGPoint endPoint#>, <#CGGradientDrawingOptions options#>)

(20161020)
88.
CGRectContainsPoint(CGRectMake(0, 0, 1, 1), CGPointMake(1,1));// NO
CGRectContainsPoint(CGRectMake(0, 0, 1, 1), CGPointMake(1,0.5));// NO
CGRectContainsPoint(CGRectMake(0, 0, 1, 1), CGPointMake(0.5,0.5));// YES

(20161027)
89. 字符串: 优先判断是否未空, 其次是否为nil.

(20161028)
90. UIView:
(1). (Autolayout,autoresizingMask) 不要和 (transform) 一起用.
(2). 使用transform时,禁用frame(使用bounds和center);
(3). frame由bounds,center,transform,anchorPoint共同决定.
(4). transform非identity时, 可以使用center来改变位置, 使用bounds的size来改变大小.

@property(nonatomic) CGRect frame;
Description
The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
This rectangle defines the size and position of the view in its superview’s coordinate system. You use this rectangle during layout operations to size and position the view. Setting this property changes the point specified by the center property and the size in the bounds rectangle accordingly. The coordinates of the frame rectangle are always specified in points.
Warning
If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.
Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

CGPathAddArc YES-逆时针 NO-顺时针 (类似函数中的YES/NO都是同样的含义)

//虽然顺时针参数是YES,在iOS中的UIView中,这里实际是逆时针。所以只会画出1/4。

CGPathAddArc(path, &transform, 50, 50, 50, 0, 1.5 * M_PI, YES);

口诀:
YES弧度顺时针算,逆时针画. => 顺算逆画
NO弧度逆时针算,顺时针画. => 逆算顺画

实习笔记

GETs

(10250810)
1. push到分支

git push --set-upstream origin f_yuyuan_copy_to_pasteboard

2. diff比较某个文件commit前后差异

git log -p -1 proj/utility/categories/NSDictionary+MS/NSDictionary+MS.m

(20150811)
3. 保存命令行别名

alias goagent='python ~/Documents/goagent-3.0/local/proxy.py'

4. git, 从stage到unstage状态

git reset HEAD proj/utility/categories/NSDictionary+MS/NSDictionary+MS.m

5. @property(atomic, strong, readwrite) ->默认属性标签

(20150813)
6. 判断字符串中是否含有emoji:

====code begin====
+ (BOOL)textIsAllExpression:(NSString *)string
{
    __block BOOL returnValue = NO;
    [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
     ^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
         returnValue = [self isEmoj:substring];
         *stop = !returnValue;
     }];
    
    return returnValue;
}

+ (BOOL)isEmoj:(NSString *)string
{
    const unichar hs = [string characterAtIndex:0];
    // surrogate pair
    if (0xd800 <= hs && hs <= 0xdbff) {
        if (string.length > 1) {
            const unichar ls = [string characterAtIndex:1];
            const int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
            if (0x1d000 <= uc && uc <= 0x1f77f) {
                return YES;
            }
        }
    } else if (string.length > 1) {
        const unichar ls = [string characterAtIndex:1];
        if (ls == 0x20e3) {
            return YES;
        } else if (hs == 0x263a && ls == 0xfe0f) {
            return YES;
        }
    } else {
        // non surrogate
        if (0x2100 <= hs && hs <= 0x27ff) {
            return YES;
        } else if (0x2B05 <= hs && hs <= 0x2b07) {
            return YES;
        } else if (0x2934 <= hs && hs <= 0x2935) {
            return YES;
        } else if (0x3297 <= hs && hs <= 0x3299) {
            return YES;
        } else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b || hs == 0x2b50) {
            return YES;
        }
    }
    return NO;
}
====code end====

(20150814)
7. 注册TableCell的Nib

[self.tableView registerNib:[UINib nibWithNibName:@"MYTopicDetailCell" bundle:nil] forCellReuseIdentifier:DetailIdentifier];

8. git回滚到merge之前

git reset --hard [版本号]

(20150815)
9. UIScrollView/UITableView滚动到顶部.

[tableView setContentOffset:CGPointMake(0, -weakSelf.tableView.contentInset.top) animated:YES];

10. UIScrollView/UITableView, 设置点击statusBar滚动到顶部.

tableView.scrollsToTop = YES;

11. git合并.

git checkout [接受被合并分支的分支]
git fetch
git merge [被合并的分支, 可以是本地或远端分支]

(20150821)
12. error在函数的声明中的类型:(NSError * __autoreleasing *)outError

(20150822)
13. UITableView和UICollectionView记得设置dataSource和delegate.

14. 和白色配的底色 r, g, b

137, 116, 185
75, 185, 146
52, 153, 225
134, 158, 83

(20150824)
15. UITableView设置UITableCell的separator的inset:(适用iOS7&8)

(1)(这步可省略, 但是要设置的话一定要同时设置)在给tableView设置时需要同时设置layoutMargins和seperatorInsects.

if ([_menuTableView respondsToSelector:@selector(setLayoutMargins:)]) {
        _menuTableView.layoutMargins = _separatorInsects;
    }
_menuTableView.separatorInset = _separatorInsects;

(2) 在-tableView:willDisplayCell:forRowAtIndexPath:设置如下

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:_menuTableView.separatorInset];
        if (indexPath.row == _menuItems.count - 1) {
            // 隐藏最后一个separater
            [cell setSeparatorInset:UIEdgeInsetsMake(0, cell.bounds.size.width, 0, 0)];
        }
    }    
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:_menuTableView.layoutMargins];
    }
}

(20150826)
16.
// 修复iOS9 TTTAttributedLabel中CTFramesetterCreateFrame因包含”\r”而陷入内存暴涨问题
// content是一个TTTAttributedLabel对象.

self.content.text = [self.content.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];

(20150827)
17. 监听屏幕旋转事件

[defaultCenter addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]];

(20150906)
18. UIViewController添加/删除child UIViewController
(1)Add
/*If you are implementing your own container view controller, it must call the didMoveToParentViewController: method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the addChildViewController: method.*/

[self addChildViewController:controller];
    [self.view addSubview:controller.view];
    [controller didMoveToParentViewController:self];

(2)Remove

[controller willMoveToParentViewController:nil];
    [controller.view removeFromSuperView];
    [controller removeFromParentViewController:self];

19. 打开Xcode的搜索栏 Cmd+Shift+F

(20150908)
20. 定制状态栏

#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) UIWindow *statusbarWindow;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // 初始化一个状态条级别的window
    CGRect frame = CGRectMake(0.0, 0.0, 320.0, 20.0);
    _statusbarWindow = [[UIWindow alloc] initWithFrame:frame];
    [_statusbarWindow setBackgroundColor:[UIColor blackColor]];
    [_statusbarWindow setWindowLevel:UIWindowLevelStatusBar + 1.0];
}

@end

(20150911)
21. objc_setAssociatedObject
The behavior you assign determines how the memory is managed for the type. If you choose retain or copy the object will be released when the instance of the class you add the associated reference to is deallocated. That makes retain and copy behavior operations preferred for Objective-C classes. Assign is also useful to avoid retain cycles as long as you set the reference to nil when done with the object.

OBJC_ASSOCIATION_ASSIGN Specifies a weak reference to the associated object.
OBJC_ASSOCIATION_RETAIN_NONATOMIC Specifies a strong reference to the associated object, and that the association is not made atomically.
OBJC_ASSOCIATION_COPY_NONATOMIC Specifies that the associated object is copied, and that the association is not made atomically.
OBJC_ASSOCIATION_RETAIN Specifies a strong reference to the associated object, and that the association is made atomically.
OBJC_ASSOCIATION_COPY Specifies that the associated object is copied, and that the association is made atomically.

22. git 合并冲突标志(8个<) <<<<<<< HEAD ...(执行git merge命令的branch的代码) ======= ...(git merge命令的参数中的分支对应的代码) >>>>>>> proj_v2.6.0

(20150915)
23. UIImage.size
In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points. In iOS 3.x and earlier, this value always reflects the dimensions of the image measured in pixels.

UIImage.scale
If you load an image from a file whose name includes the @2x modifier, the scale is set to 2.0. You can also specify an explicit scale factor when initializing an image from a Core Graphics image. All other images are assumed to have a scale factor of 1.0.
*notice*
If you multiply the logical size of the image (stored in the size property) by the value in this property, you get the dimensions of the image in pixels.

(20150919)
24. //@fix ios7 下 没设置 forState title 左右的数据会出错。

...
    UIButton *_likeCountButton = ...;
    if (likeCountButtonSelected) {
        _likeCountButton.selected = YES;
        [_likeCountButton setTitle:likeTitle forState:UIControlStateSelected];
    } else {
        _likeCountButton.selected = NO;
        [_likeCountButton setTitle:likeTitle forState:UIControlStateNormal];
    }

25. 刷新时button闪烁,把button类型改成custom就不会闪烁了.

(20150922)
26. UINavigationBar外观显示设置

// 设置导航栏背景不透明,且为白色.
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
    // 隐藏导航栏底部1px的灰色边线
    [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
                                      forBarPosition:UIBarPositionAny
                                          barMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

26. #define使用

#define STARTLOGTIME \
    do{((AppDelegate *)[UIApplication sharedApplication].delegate).startTime = CFAbsoluteTimeGetCurrent();}while(0)
#define LOGTIME(x) \
    do{int count = x; NSLog(@"<%d<<<: %lf", count, CFAbsoluteTimeGetCurrent() - ((AppDelegate *)[UIApplication sharedApplication].delegate).startTime);}while(0)
@property (nonatomic, assign) CFAbsoluteTime startTime;

(20150925)
27. 用UICollectionView的时候, 在xib中给UICollectionViewCell添加tap手势(可能)会导致以下错误:
*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/UICollectionView.m:3589

28. 使用UIView的layoutIfNeed函数来更新布局, 只有在约束有更改的情况下才会更新布局哦.

(20150929)
29. 菜头曾说过,“性是网络第一生产力,无聊是网络第二生产力,免费是网络第三生产力。三力结合,基本上可以解释一切网络热点事件。”

(20150930)
30. 删除函数实现的时候, 注意查看是否在.h头文件中有函数声明, 如果有声明, 应该将声明一并删除, 以防调用未实现函数.

31. Xcode手动生成Warning,error,…

//Generate a warning
#pragma message "Warning 1"
--------
//Another way to generate a warning
#warning "Warning 2"
--------
//Generate an error to fail the build.
#error "Something wrong"
--------
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
int a;
#pragma clang diagnostic pop

(20151009)
32. Mantle中不必要的Transformer: 如果解析字段对应的值是字符串数组, 则不需要配置对应的JSONTransformer.

// 此段代码不需要
// 写上会导致解析异常, 奔溃.
/*
+ (NSValueTransformer *)tagsJSONTransformer {
    return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:[NSString class]];
}
*/

(20151012)
33. Git修改branch的名称 If you’re currently on the branch you want to rename:

git branch -m new_name

(20151013)
34. 手势的响应方法格式

// Valid action method signatures:
//     -(void)handleGesture;
//     -(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer;
- (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action NS_DESIGNATED_INITIALIZER; // designated initializer

(20151014)
35. 可以运行带有 –delete 选项的 git push 命令来删除一个远程分支。 如果想要从服务器上删除 serverfix 分支,运行下面的命令:

$ git push origin --delete serverfix
To https://github.com/schacon/simplegit
 - [deleted]         serverfix

(20151023)
36. iPhones设备型号

if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G (A1203)";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G (A1241/A1324)";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS (A1303/A1325)";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4 (A1332)";
if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4 (A1332)";
if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (A1349)";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S (A1387/A1431)";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (A1428)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (A1429/A1442)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (A1456/A1532)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (A1507/A1516/A1526/A1529)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (A1453/A1533)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (A1457/A1518/A1528/A1530)";
if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus (A1522/A1524)";
if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6 (A1549/A1586)";

(20151027)
37. NS_REQUIRES_NIL_TERMINATION

(20151104)
38. libc++abi.dylib: terminate_handler unexpectedly threw an exception
可能原因是有一些无用的IBOutlet未删除.

(20151104)
39. CGImageRef使用时,需要按实际情况使用CGImageRelease(imageRef)来释放内存!_!

(20151105)
40. 判断一个UIViewController是否内存泄露的方法: 看-dealloc是否执行!!!
所以, 以后每个UIViewController都要写-dealloc方法, 备用!

41. 传入Block的变量尽量设置为weak; Block执行完之后最好手动置为nil;

(20151110)
42. 更新插件的DVTPlugInCompatibilityUUID(后话:可能会导致Xcode不能启动, 或其他问题.)

find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID`

(20151119)
44. 人活着, 为了什么? 生命的意义在于什么? 活着, 第一, 就是意识到这个问题, 并去思考它. 第二步, 迷茫过后, 让生活与生命变得简单, 活着是最根本直接的目的. 在此基础上, 我们学会了思考第一点, 同时学会了想要去实现, 去获得许多事和许多物. 第二步就是给自己空白的生命定上一个目标(当然可以有很多目标), 并去实现它(们). 第三步, 瞄准我们定下的目标, 抛弃其他的杂念, 认认真真的去为完成这个目标而不断努力, 用汗水+思考去把空白空虚的生命丰富. 第三步会随着你的目标的不同, 过程也会变得长短不一, 或精彩或平淡. 当我们实现了第二步定下的目标后, 也许我们会重新回去思考, 即又回到第一步. 但是一般推荐直接回到第二步, 给自己在定下下一个目标. 只要活着, 我们的生命就会不停地以空白的状态出现在我们的生活中, 那就去继续用第三步的充实生活去书写你的生命!

代码提取&代码行数统计(Linux&Mac)

1.统计demo目录下,js文件数量:

find demo/ -name “*.js” |wc -l

2.统计demo目录下所有js文件代码行数:

find demo/ -name “*.js” |xargs cat|wc -l 或 wc -l `find ./ -name “*.js”`|tail -n1

3.统计demo目录下所有js文件代码行数,过滤了空行:

find /demo -name “*.js” |xargs cat|grep -v ^$|wc -l
参考:http://www.cnblogs.com/fullhouse/archive/2011/07/17/2108786.html