0%

前言

在项目新版本中,要实现类似以下的效果:给每个section区域添加一个卡片装饰背景以及一个袖标装饰图标(卡片在所有的cell下,袖标在cell上面)。

效果-1.png

效果-2.png

这可以通过UICollectionViewDecorationView 特性来达到以上效果。本文主要是总结 DecorationView 的实现、重用机制和存在的坑。

Read more »

为了安全性,个人的github和公司的gitlab需要配置不同的SSH-Key。具体如下:

  1. 切换到系统的SSH目录

    1
    cd ~/.ssh
  2. 为个人的github生成SSH-Key(若还没有)

    1
    ssh-keygen -t rsa -C "your_mail@example.com" -f github_rsa

    然后,前往github添加SSH公钥。

  3. 为公司的gitlab生成SSH-Key(若还没有)

    1
    ssh-keygen -t rsa -C "your_mail@company.com" -f company_rsa

    然后,前往gitlab添加SSH公钥。

  4. 添加配置文件(若还没有)

    1
    touch config
  5. 为配置文件config添加如下内容

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # github.com
    Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/github_rsa

    # gitlab.company.com
    Host gitlab.company.com
    HostName gitlab.company.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/company_rsa
  6. 测试

    1
    ssh -T git@github.com

    输出:

    Hi YK-Unit! You’ve successfully authenticated, but GitHub does not provide shell access.

    以上表示成功连接到了个人的github。
    然后可以用同样方式测试公司的gitlab。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//代码片段摘自苹果开源的runtime代码(objc4-208版本)
//https://opensource.apple.com/source/objc4/objc4-208/runtime/objc-class.h
struct objc_class {
struct objc_class *isa;
struct objc_class *super_class;
const char *name;
long version;
long info;
long instance_size;
struct objc_ivar_list *ivars;

#if defined(Release3CompatibilityBuild)
struct objc_method_list *methods;
#else
struct objc_method_list **methodLists;
#endif

struct objc_cache *cache;
struct objc_protocol_list *protocols;
};

这是Objective-C 2.0中的类的代码,相信做iOS开发的同学都很熟悉的了。有天在查资料又看到它的时候,想到了一个好奇的问题:

methodLists 是一个二级指针,在内存中,它指向的是什么呢?(或者说,其指向的数据结构到底是怎么样的?)

Read more »

在 Mac 下写 C 的时候,如果程序并不复杂,其实蛮不愿意打开 Xcode 这个庞然大物的。为此,特意找时间解决了这个事情:Atom + Atom 插件 = C 轻量级 IDE

下面将会列出所用到的主要插件:

  • autocomplete-clang
    autocomplete for C/C++/ObjC using clang

  • build
    Build your current project, directly from Atom

  • linter
    A Base Linter with Cow Powers to visualize errors and other kind-of messages, easily

  • linter-clang
    A linter plugin for Linter provides an interface to clang

  • script
    Run code in Atom!

    在 Mac 下,按 cmd-i ,该插件就会调用 clang 编译并运行当前的 c 程序

安装完毕后,开始你的 C 旅程吧~