日常零零碎

一. 打开Mac OSX原生的读写NTFS功能

插上磁盘打开终端, 输入一下命令:

1
2
3
diskutil list
sudo nano /etc/fstab
LABEL=Elements none ntfs rw,auto,nobrowse
  1. 重启
1
sudo ln -s /Volumes/lj ~/Desktop/lj

二. 打开允许所有来源:

1
$ sudo spctl --master-enable

三. Mac 隐显文件

1
2
3
4
# 显示隐藏文件
$ defaults write com.apple.finder AppleShowAllFiles Yes && killall Finder
# 不显示隐藏文件
$ defaults write com.apple.finder AppleShowAllFiles No && killall Finder

四. chisel使用

1
2
$ brew update
$ brew install chisel
1
2
$ touch .lldbinit 
$ open .lldbinit
1
2
3
# ~/.lldbinit
...
command script import /usr/local/opt/chisel/libexec/fblldb.py

or

1
2
3
# ~/.lldbinit
...
command script import /path/to/fblldb.py

五. 打印Model

  1. 创建一个BaseModel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
- (NSString *)debugDescription
{
//声明一个字典
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];

//得到当前class的所有属性
uint count;
objc_property_t *properties = class_copyPropertyList([self class], &count);

//循环并用KVC得到每个属性的值
for (int i = 0; i<count; i++) {
objc_property_t property = properties[i];
NSString *name = @(property_getName(property));
id value = [self valueForKey:name]?:@"nil";//默认值为nil字符串
[dictionary setObject:value forKey:name];//装载到字典里
}

//释放
free(properties);

NSString *desc = [NSString stringWithFormat:@"<%@-%p> -- %@",[self class],self,dictionary];
desc = [NSString stringWithCString:[desc cStringUsingEncoding:NSUTF8StringEncoding] encoding:NSNonLossyASCIIStringEncoding];
return desc;
}
  1. 目标model
1
2
3
4
- (NSString *)description
{
return [super debugDescription];
}
  1. 打印
1
2
3
4
5
2018-08-26 00:18:44.008746+0800 DebugDescriptionDemo[6390:45917] <TestModel-0x100506560> -- {
index = 1;
text = "降龙十八掌";
}
Program ended with exit code: 0

六. edgesForExtendedLayout的使用

视图顶部高度

1
2
3
4
5
6
7
@property(nonatomic, assign) UIRectEdge edgesForExtendedLayout;
Description
The edges that you extend for your view controller.
Instead of this property, use the safe area of your view to determine which parts of your interface are occluded by other content. For more information, see the safeAreaLayoutGuide and safeAreaInsets properties of UIView.
In iOS 10 and earlier, use this property to report which edges of your view controller extend underneath navigation bars or other system-provided views. The default value of this property is UIRectEdgeAll, and it is recommended that you do not change that value.
If you remove an edge value from this property, the system does not lay out your content underneath other bars on that same edge. In addition, the system provides a default background so that translucent bars have an appropriate appearance. The window’s root view controller does not react to this property.
SDKs iOS 7.0+, tvOS 9.0+

七. Mac无法上网, 清除网络配置文件

  1. 打开一下路劲

    1
    /资源库/Preferences/SystemConfiguration/
  2. 删除文件

    1
    2
    3
    4
    com.apple.airport.preferences.plist
    com.apple.network.identification.plist
    NetworkInterfaces.plist
    preferences.plist
  3. 清空废纸篓

  4. 重启

八. Mac U盘装系统

  1. 打开App Store 下载系统(以EI Capition为例)

  2. 插入U盘并且更改U盘名称(123为例)

  3. 打开终端输入

1
$ sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/123 --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app
1
$ sudo /Applications/macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/123 --applicationpath /Applications/macOS\ High\ Sierra.app
  1. 输入管理员密码

  2. 输入y

  3. 最后等待,启动盘制作成功

  4. 重启,按住Option不松手,启动之后看到U盘,点击继续,点击“磁盘工具”抹掉全部的磁盘 (**一定要记得合并成1个分区,有多个分区是无法安装成功的)然后关闭,回到实用工具的界面,点击“重新安装OS X”覆盖掉目前的磁盘就可以。

  5. 如果有卡在最后一秒的界面,也别急,最长可能也需要30分钟。就接着电源放着等待就可以了。