-
Notifications
You must be signed in to change notification settings - Fork 236
/
QMUI_property_swizzle_weak.codesnippet
36 lines (35 loc) · 1.49 KB
/
QMUI_property_swizzle_weak.codesnippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>propertySwizzleWeak_QMUI</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>ClassImplementation</string>
</array>
<key>IDECodeSnippetContents</key>
<string>static char kAssociatedObjectKey_<#property name#>;
- (void)set<#property name#> {
QMUIWeakObjectContainer *weakContainer = objc_getAssociatedObject(self, &kAssociatedObjectKey_<#property name#>);
if (!weakContainer) {
weakContainer = [QMUIWeakObjectContainer new];
}
weakContainer.object = <#argument name#>;
objc_setAssociatedObject(self, &kAssociatedObjectKey_<#property name#>, weakContainer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- <#property getter#> {
return (<#property type#> *)((QMUIWeakObjectContainer *)objc_getAssociatedObject(self, &kAssociatedObjectKey_<#property name#>)).object;
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>5BD3118C-1D72-471C-BED5-AF14D9EE54FF</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Objective-C</string>
<key>IDECodeSnippetTitle</key>
<string>QMUI - 用swizzle方式创建weak类型的property的getter/setter</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>