Fix crash when call needsMainThreadDeallocation on NSProxy instances #trivial (#965)

This commit is contained in:
Huy Nguyen
2018-06-12 19:32:11 +01:00
committed by GitHub
parent 5c13cbe7a2
commit 42ac10aac3
2 changed files with 23 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
* class need to be deallocated on the main thread.
* You do not access this property yourself.
*
* The NSObject implementation returns NO if the class name has
* The NSObject implementation returns YES if the class name has
* a prefix UI, AV, or CA. This property is also overridden to
* return fixed values for other common classes, such as UIImage,
* UIGestureRecognizer, and UIResponder.
@@ -43,5 +43,18 @@ NS_ASSUME_NONNULL_BEGIN
@end
@interface NSProxy (ASNeedsMainThreadDeallocation)
/**
* Override this property to indicate that instances of this
* class need to be deallocated on the main thread.
* You do not access this property yourself.
*
* The NSProxy implementation returns NO because
* proxies almost always hold weak references.
*/
@property (class, readonly) BOOL needsMainThreadDeallocation;
@end
NS_ASSUME_NONNULL_END

View File

@@ -199,3 +199,12 @@
}
@end
@implementation NSProxy (ASNeedsMainThreadDeallocation)
+ (BOOL)needsMainThreadDeallocation
{
return NO;
}
@end