High Quality iOS
Development
***@robinlu
IN-SRC Studio
Saturday, April 9, 2011
Quality
Saturday, April 9, 2011
Topics
• Memory management
• To o l s
• Crash Reports
• Test
Saturday, April 9, 2011
Memory Management
Saturday, April 9, 2011
Memory Management
alloc object
+1 -1
copy reference release
retain count
0
dealloc
Saturday, April 9, 2011
Ownership
Declare ownership Release ownership
• create / copy • don’t need anymore
• instance variable • dealloc of owner
• container
• multi-thread
• ...
Saturday, April 9, 2011
Autorelease
• give the ownership to autorelease pool
• default autorelease pool created by AppKit
• life cycle = event cycle
• You can create your own autorelease pool
• Don’t over use autorelease
Saturday, April 9, 2011
Problems
• Memory Leak
• Over-release
Saturday, April 9, 2011
Rules
You only release or autorelease
objects you own
• If you own the object by alloc, copy or
retain, you have to release or autorelease
• If the object is not owned by you, don’t call
release or autorelease
Saturday, April 9, 2011
Pitfalls
• Implicit Onwership
• Circular Reference
Saturday, April 9, 2011
开发高质量的iOS应用 来自淘豆网m.daumloan.com转载请标明出处.