Skip to content

Commit

Permalink
fix #892
Browse files Browse the repository at this point in the history
  • Loading branch information
longitachi committed Mar 6, 2024
1 parent b3418f4 commit cc5f39b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ let package = Package(
.target(
name: "ZLPhotoBrowser",
path: "Sources",
exclude: ["Info.plist"],
exclude: [
"Info.plist",
"General/ZLWeakProxy.h",
"General/ZLWeakProxy.m"
],
resources: [
.process("ZLPhotoBrowser.bundle")
]
Expand Down
52 changes: 52 additions & 0 deletions Sources/General/ZLWeakProxy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// ZLWeakProxy.swift
// ZLPhotoBrowser
//
// Created by long on 2024/3/6.
//
// Copyright (c) 2020 Long Zhang <495181165@qq.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#if SWIFT_PACKAGE

import UIKit

class ZLWeakProxy: NSObject {
private weak var target: NSObjectProtocol?

init(target: NSObjectProtocol) {
self.target = target
super.init()
}

class func proxy(target: NSObjectProtocol) -> ZLWeakProxy {
return ZLWeakProxy(target: target)
}

override func forwardingTarget(for aSelector: Selector!) -> Any? {
return target
}

override func responds(to aSelector: Selector!) -> Bool {
return target?.responds(to: aSelector) ?? false
}
}

#endif
4 changes: 4 additions & 0 deletions ZLPhotoBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
FD21E4E1272FFE8E00D1D168 /* ZLPhotoConfiguration+Chaining.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD21E4E0272FFE8E00D1D168 /* ZLPhotoConfiguration+Chaining.swift */; };
FD24655828E2A96200C15B20 /* UIView+ZLPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD24655728E2A96200C15B20 /* UIView+ZLPhotoBrowser.swift */; };
FD34FC622AD25A2100AE4344 /* UIScrollView+ZLPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD34FC612AD25A2100AE4344 /* UIScrollView+ZLPhotoBrowser.swift */; };
FD3B66982B984BB0009C7353 /* ZLWeakProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3B66972B984BB0009C7353 /* ZLWeakProxy.swift */; };
FD4C971B29F11918000249BF /* ZLCollectionViewFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD4C971A29F11918000249BF /* ZLCollectionViewFlowLayout.swift */; };
FD5230B5281562DD0034B782 /* ZLEnlargeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD5230B4281562DD0034B782 /* ZLEnlargeButton.swift */; };
FD74F6DD29345E4100B7916A /* ZLBaseStickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD74F6DC29345E4100B7916A /* ZLBaseStickerView.swift */; };
Expand Down Expand Up @@ -137,6 +138,7 @@
FD21E4E0272FFE8E00D1D168 /* ZLPhotoConfiguration+Chaining.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ZLPhotoConfiguration+Chaining.swift"; sourceTree = "<group>"; };
FD24655728E2A96200C15B20 /* UIView+ZLPhotoBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+ZLPhotoBrowser.swift"; sourceTree = "<group>"; };
FD34FC612AD25A2100AE4344 /* UIScrollView+ZLPhotoBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScrollView+ZLPhotoBrowser.swift"; sourceTree = "<group>"; };
FD3B66972B984BB0009C7353 /* ZLWeakProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLWeakProxy.swift; sourceTree = "<group>"; };
FD4C971A29F11918000249BF /* ZLCollectionViewFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLCollectionViewFlowLayout.swift; sourceTree = "<group>"; };
FD5230B4281562DD0034B782 /* ZLEnlargeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLEnlargeButton.swift; sourceTree = "<group>"; };
FD74F6DC29345E4100B7916A /* ZLBaseStickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLBaseStickerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -276,6 +278,7 @@
FDAE00A8297134C100EE9486 /* ZLAnimationUtils.swift */,
FDCBAF9F2B1ED0A9000860FD /* ZLWeakProxy.h */,
FDCBAF9E2B1ED0A9000860FD /* ZLWeakProxy.m */,
FD3B66972B984BB0009C7353 /* ZLWeakProxy.swift */,
);
path = General;
sourceTree = "<group>";
Expand Down Expand Up @@ -399,6 +402,7 @@
FD24655828E2A96200C15B20 /* UIView+ZLPhotoBrowser.swift in Sources */,
E4943ABB255A652A00C29B3A /* CGFloat+ZLPhotoBrowser.swift in Sources */,
FDC8ED0B2B0F4032002EB8B9 /* UIGraphicsImageRenderer+ZLPhotoBrowser.swift in Sources */,
FD3B66982B984BB0009C7353 /* ZLWeakProxy.swift in Sources */,
E4765DFB25415F87007B2C0F /* ZLImagePreviewController.swift in Sources */,
FDB34114280D0D70008F20B3 /* ZLPhotoUIConfiguration.swift in Sources */,
E466804724FB76C50011E332 /* ZLEditVideoViewController.swift in Sources */,
Expand Down

0 comments on commit cc5f39b

Please sign in to comment.