This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ``` | |
| iptables -A OUTPUT -p tcp --match multiport --dports 25,109,110,143,465,993,995 -m state --state NEW,ESTABLISHED -j REJECT | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## App Group | |
| App Group 是一个 App 与其扩展均可以访问的本地文件系统的一块区域。由于 Watch App 与 iOS App 是在不同的沙盒环境下运行,正常情况下他们彼此无法分享数据,因此,我们需要创建一个 App Group,使的它们拥有一个共享的文件区域。 | |
| 点击项目,在 target 里分别打开项目本身和 Watch App 的 App Groups,点击加号,添加一个 App Group,输入一个唯一的标识符。我们之后会在 Watch App 和 iOS App 中通过该标识符访问同一个 App Group。 | |
|  | |
| ## NSUserDefault |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架)。而若要指定某几个角(小于4)为圆角而别的不变时,这种方法就不好用了。 | |
| 对于这种情况,Stackoverflow上提供了几种解决方案。其中最简单优雅的方案,就是使用`UIBezierPath`。下面给出一段示例代码。 | |
| UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)]; | |
| view2.backgroundColor = [UIColor redColor]; | |
| [self.view addSubview:view2]; | |
| UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)]; | |
| CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; | |
| maskLayer.frame = view2.bounds; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UITableViewCell 设置AutoLayoutCell的时候遇见到`UIView-Encapsulated-Layout-Height(44)`的坑。 | |
| 看起来像是autolayout在ios8上面的bug,等着苹果啥时候能解决... | |
| 后来用@999来解决了= =,实在是无力吐槽了,这里记一笔先,下面是链接。 | |
| [这是stackoverflow上面的讨论](http://stackoverflow.com/questions/25059443/what-is-nslayoutconstraint-uiview-encapsulated-layout-height-and-how-should-i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 教你如何发布自己的代码到CocoaPods | |
| 很多人问起自己的项目如何发布到CocoaPods呢?不少人有这样的疑惑,其实都是没去看官方文档。。 | |
| ## 注册 | |
| CocoaPods 需要0.33版本以上的,用`pod --version`查看,不是0.33的话就更新一下 | |
| 下一步注册一个账号 | |
| ``` | |
| pod trunk register zhuchao@iosx.me 'zhuchao' --description='macbook pro x72' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Background Fetch | |
| * 开启 | |
| 首先在info plist文件中开启UIBackgroundModes的Background fetch。或者手动编辑这个值 | |
| ``` | |
| <key>UIBackgroundModes</key> | |
| <array> | |
| <string>fetch</string> | |
| </array> | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 随着苹果发布了swift语言,很多人拿OC与之对比,下面是苹果列出的Swift几项特性(它们不包含Objective-C已经有的特性,比如自动内存管理) | |
| * 类型推断(Inferred types) – 类型推断让代码更清晰以及更少的错误 | |
| * 模块(Modules) – 模块移除了头文件并提供命名空间 | |
| * 闭包和函数(Closures & Functions) – 闭包和函数指针相匹配 | |
| * 元组(Tuples) – 元组和多重返回值 | |
| * 泛型(Generics) – 泛型带来的好处是不言而喻的。 | |
| * 结构体(Structs) – 支持方法、扩展、接口的结构体。 | |
| * 函数式编程模式(Functional Programming Patterns) – 比如map和filter。 | |
| 这些都是在Objective-C基础上显而易见的改进。让我们将关于泛型的好处、类型推断、函数式编程等等的争论放到一边,干脆的同意Swift在许多地方比Objective-C要优越。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * 1.`NSKernAttributeName: @10` 调整字句 kerning 字句调整 | |
| * 2.`NSFontAttributeName : [UIFont systemFontOfSize:_fontSize]` 设置字体 | |
| * 3.`NSForegroundColorAttributeName :[UIColor redColor]` 设置文字颜色 | |
| * 4.`NSParagraphStyleAttributeName : paragraph` 设置段落样式 | |
| `NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; | |
| paragraph.alignment = NSTextAlignmentCenter;` | |
| * 6.`NSBackgroundColorAttributeName: [UIColor blackColor]` 设置背景颜色 | |
| * 7.`NSStrokeColorAttributeName: [UIColor blackColor]`设置文字描边颜色, | |
| * 8.`NSStrokeWidthAttributeName: [NSNumber numberWithFloat:2.0f]`设置描边宽度, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 今天把现有APP在IOS9上编译了一次发现,所有请求都是timeout | |
| ```bash | |
| 2015-06-12 10:32:42.087 mcapp[8300:226922] Failed:Error | |
| Domain=NSURLErrorDomain Code=-1001 "The request timed out." | |
| UserInfo=0x7f9b18cdc420 {NSUnderlyingError=0x7f9b18f49e80 "The request timed | |
| out.", NSErrorFailingURLStringKey=https://***.maichong.me/***/share-data?, | |
| NSErrorFailingURLKey=https://***.maichong.me/***/share-data?, | |
| _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, | |
| NSLocalizedDescription=The request timed out.} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## golang 模板调用接口函数 | |
| [http://stackoverflow.com/questions/10200178/call-a-method-from-a-go-template](http://stackoverflow.com/questions/10200178/call-a-method-from-a-go-template) | |
| You can even pass parameters to function like follows | |
| ``` | |
| type Person struct { | |
| Name string | |
| } | |
| func (p *Person) Label(param1 string) string { |