iOS App 开发问题汇总(六)

1. The data couldn’t be read because it isn’t in the correct format.

A:项目是2014年开发的,打包导出 Ad-hoc 时报上面的错误,Build Setting > Enable Bitcode > NO 之后再试成功了。

Reference:ipatool fails to build with bitcode (xcode 7.1.1)

2.setNeedsLayout vs. setNeedsUpdateConstraints and layoutIfNeeded vs updateConstraintsIfNeeded

A:

  • If you manipulated constraints directly, call setNeedsLayout.
  • If you changed some conditions (like offsets or smth) which would change constraints in your overridden updateConstraints method (a recommended way to change constraints, btw), call setNeedsUpdateConstraints, and most of the time, setNeedsLayout after that.
  • If you need any of the actions above to have immediate effect—e.g. when your need to learn new frame height after a layout pass—append it with a layoutIfNeeded.

Reference:setNeedsLayout vs. setNeedsUpdateConstraints and layoutIfNeeded vs updateConstraintsIfNeeded

3.父类如何关联子类通过nib初始化的属性?

A: Select xib > Show Utilities > Show The Connection In Inspector > + > Connect to View

继续阅读

Debian 使用笔记

1. Install pear on Debian

A:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$ wget http://pear.php.net/go-pear.phar
$ sudo php go-pear.phar

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /home/meiliang/pear
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /home/meiliang/pear/bin
 5. PHP code directory ($php_dir)                 : /home/meiliang/pear/share/pear
 6. Documentation directory                       : /home/meiliang/pear/docs
 7. Data directory                                : /home/meiliang/pear/data
 8. User-modifiable configuration files directory : /home/meiliang/pear/cfg
 9. Public Web Files directory                    : /home/meiliang/pear/www
10. System manual pages directory                 : /home/meiliang/pear/man
11. Tests directory                               : /home/meiliang/pear/tests
12. Name of configuration file                    : /home/meiliang/.pearrc

1-12, 'all' or Enter to continue: 1
(Use $prefix as a shortcut for '/home/meiliang/pear', etc.)
Installation base ($prefix) [/home/meiliang/pear] : /usr/local/bin/pear

$ vim .bashrc
# Append the /usr/local/bin/pear directory in the user's home directory onto the PATH environment variable
export PATH=$PATH:/usr/local/bin/pear/bin

// Reload bash configure file
$ source .bashrc

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/bin/pear/bin

// Check wether it works
$ pear version
PEAR Version: 1.10.1
PHP Version: 5.6.17-0+deb8u1
Zend Engine Version: 2.6.0
Running on: Linux Debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64
继续阅读

iOS 面试题汇总(三)

1.Difference between categories and extensions?

A:There are three difference beween categories and extensions:

  1. The extension has no name;
  2. The implementation of the extension must be in the main @implementation block of the file;
  3. The extension can easy declare property that need backend instance variable.

Reference:Difference between Category and Class Extension?

2.What is advantage of category?

A:

  • You can add method to existing class even to that class whose source is not available to you.
  • You can extend functionality of a class without subclassing.
  • You can split implementation in multiple files.

3.What are KVO and KVC?

A:

Key-value observing is a mechanism that enables an object to be notified directly when a property of another object changes.

Key-value coding is a mechanism for indirectly accessing an object’s attributes and relationships using string identifiers.

Reference:Cocoa Core Competencies

继续阅读