In many Books and on many Sites I see -drain. Well, for an Autorelease Pool that sounds cool. But does it do anything other than an release? I would guess -drain just makes the Pool to -release all it's objects, without releasing the Pool itself. Just a guess.
相关问题
- CALayer - backgroundColor flipped?
- What uses more memory in c++? An 2 ints or 2 funct
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- Achieving the equivalent of a variable-length (loc
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Converting (u)int64_t to NSNumbers
- Can keyboard of type UIKeyboardTypeNamePhonePad be
Oxigen is right, see the documentation for method
drain
of NSAutoreleasePool:If your system has a garbage Collection, then -drain send message (objc_collect_if_needed) for GC
If you haven't GC, then drain = release
Note that the comments on oxigen's answer saying that -drain does not release the NSAutoreleasePool are not correct. The documentation for NSAutoreleasePool clearly says that -drain releases (and thus destroys) the NSAutoreleasePool.
-drain is a replacement for using -release for NSAutoreleasePool objects, the only difference being that provides a hint to the garbage collection system.