Created
February 18, 2019 16:53
-
-
Save romyilano/b608ae257ffc2971996c268deb21b1e9 to your computer and use it in GitHub Desktop.
This is SO useful!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html | |
– (id)findMatchingObject:(id)anObject { | |
id match; | |
while (match == nil) { | |
@autoreleasepool { | |
/* Do a search that creates a lot of temporary objects. */ | |
match = [self expensiveSearchForObject:anObject]; | |
if (match != nil) { | |
[match retain]; /* Keep match around. */ | |
} | |
} | |
} | |
return [match autorelease]; /* Let match go and return it. */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment