1.Explain method swizzling. When you would use it?
A:Method swizzling is a feature of dynamic of Objective-C that use a new method implementation replace the original. When the original implement doesn’t meet my need, I will use this technology.
2.Take three objects: a grandparent, parent and child. The grandparent retains the parent, the parent retains the child and the child retains the parent. The grandparent releases the parent. Explain what happens.
A:It causes strong reference cycle, and results as memory leaks.
3.What happens when you invoke a method on a nil pointer?
Reference:nil / Nil / NULL / NSNull
4.Give two separate and independent reasons why retainCount should never be used in shipping code.
There should be no reason to explicitly ask an object what its retain count is (see retainCount). The result is often misleading, as you may be unaware of what framework objects have retained an object in which you are interested. In debugging memory management issues, you should be concerned only with ensuring that your code adheres to the ownership rules.
5.Explain your process for tracing and fixing a memory leak.
- Launch Instruments, select Leaks instrument;
- Use App normal;
- Notice spike on timeline pane;
- Check spike is normal;
- Fix any where that cause memory leak;
We also can use Allocations:
- Launch Instruments, select Allocations instrument;
- Use App normal;
- Make generation when state change;
- Compare gerations to find out memory leak;
- Fix memory leak;
6.Explain how an autorelease pool works at the runtime level.
A:As its name, it works like a pool, any object called autorelease method be throw to this pool, all object in autorelease pool will recieve a release method when it drain that occured at each event loop end.
7.When dealing with property declarations, what is the difference between atomic and non-atomic?
1 2 3 4 5 6 7 8
8.In C, how would you reverse a string as quickly as possible?
9.Which is faster: to iterate through an NSArray or an NSSet?
10.Explain how code signing works.
A:签名软件先将代码和资源使用单向 hash 算法计算出一系列的 hash 值，之后使用签名者提供的私钥来加密这些 hash 值，加密后的 hash 值存储在代码包中，在代码包中还包含签名者的证书，证书是由 Apple 签发的，能证明签名者的身份，证书里还包含签名者的公钥，操作系统之后可以使用相同的 hash 算法计算代码包里代码和资源的 hash，然后将 hash 值和用公钥解密的 hash 对比，这样就能保证代码并未被修改和确认它的来源，这就是代码签名的大致原理。
11.What is posing in Objective-C?
12.List six instruments that are part of the standard.
- Time Profiler
- Activity Monitor
- Core Animation
13.What are the differences between copy and retain?
14.What is the difference between frames and bounds?
The frame property contains the frame rectangle, which specifies the size and location of the view in its superview’s coordinate system. The bounds property contains the bounds rectangle, which specifies the size of the view (and its content origin) in the view’s own local coordinate system.
Does frames' size always equal to bounds' size?
A: No, if view’s transform is not CGAffineTransformIdentity, its may not equal.
15.What happens when the following code executes? Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];
A: The object gets released twice when the autorelease pool is drain, so it may causes app crash.
Reference:Autoreleasing twice an object
16.List the five iOS app states.
|The app has not been launched or was running but was terminated by the system.
|The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.
|The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.
|The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background
|The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code.
When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.