Skip to content

Commit

Permalink
Fix crash when call needsMainThreadDeallocation on NSProxy instances …
Browse files Browse the repository at this point in the history
…#trivial (#965)
  • Loading branch information
nguyenhuy committed Jun 12, 2018
1 parent 5c13cbe commit 42ac10a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/ASMainThreadDeallocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
9 changes: 9 additions & 0 deletions Source/ASMainThreadDeallocation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,12 @@ + (BOOL)needsMainThreadDeallocation
}

@end

@implementation NSProxy (ASNeedsMainThreadDeallocation)

+ (BOOL)needsMainThreadDeallocation
{
return NO;
}

@end

0 comments on commit 42ac10a

Please sign in to comment.