Aspect

所属分类:工具库
开发工具:Swift
文件大小:0KB
下载次数:0
上传日期:2019-12-15 04:13:25
上 传 者sh-1993
说明:  用于面向方面编程的轻量级纯Swift库,
(A lightweight, pure-Swift library for aspect oriented programming,)

文件列表:
.swiftlint.yml (2439, 2019-12-14)
Aspect.xcodeproj/ (0, 2019-12-14)
Aspect.xcodeproj/project.pbxproj (21007, 2019-12-14)
Aspect.xcodeproj/project.xcworkspace/ (0, 2019-12-14)
Aspect.xcodeproj/project.xcworkspace/contents.xcworkspacedata (135, 2019-12-14)
Aspect/ (0, 2019-12-14)
Aspect/Aspect.Arguments.swift (14622, 2019-12-14)
Aspect/Aspect.h (502, 2019-12-14)
Aspect/Aspect.swift (10281, 2019-12-14)
Aspect/AspectBlock.swift (1292, 2019-12-14)
Aspect/AspectError.swift (1501, 2019-12-14)
Aspect/AspectIdentifier.swift (5320, 2019-12-14)
Aspect/Info.plist (726, 2019-12-14)
Aspect/Lock.swift (2297, 2019-12-14)
Aspect/NSObject.Association.swift (3390, 2019-12-14)
Aspect/Objc/ (0, 2019-12-14)
Aspect/Objc/ObjCRuntimeAliases.h (272, 2019-12-14)
Aspect/Objc/ObjCRuntimeAliases.m (242, 2019-12-14)
Aspect/Runtime.swift (7704, 2019-12-14)
AspectTests/ (0, 2019-12-14)
AspectTests/AspectTests.swift (5212, 2019-12-14)
AspectTests/Info.plist (701, 2019-12-14)
Images/ (0, 2019-12-14)
Images/aspect.png (11458, 2019-12-14)
LICENSE (1070, 2019-12-14)
Package.swift (432, 2019-12-14)

[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![badge-pms](https://img.shields.io/badge/languages-Swift-orange.svg) [![Swift Version](https://img.shields.io/badge/Swift-4.0--5.0.x-F16D39.svg?style=flat)](https://developer.apple.com/swift) Aspect is a lightweight, pure-Swift library for for aspect oriented programming. This project is heavily inspired by the popular [Aspects](https://github.com/steipete/Aspects). It provides you a chance to use a pure-Swift alternative in your next app. ## Features - [x] Hook object selector - [x] Hook different classes selector in the same hierarchy - [x] Hook class and static selector - [x] Provide more friendly Swift interfaces ## Usage ### Hook object selector with OC block ``` public class Test: NSObject { @objc dynamic func test(id: Int, name: String) { } @objc dynamic static func classSelector(id: Int, name: String) { } } let test = Test() let wrappedBlock: @convention(block) (AspectInfo, Int, String) -> Void = { aspectInfo, id, name in } let block: AnyObject = unsafeBitCast(wrappedBlock, to: AnyObject.self) test.hook(selector: #selector(Test.test(id:name:)), strategy: .before, block: ) ``` ### Hook object selector with Swift block ``` let test = Test() _ = try? test.hook(selector: #selector(Test.test(id:name:)), strategy: .before) { (_, id: Int, name: String) in } ``` ### Hook class instance selector with Swift block ``` _ = try? Test.hook(selector: #selector(Test.test(id:name:)), strategy: .before) { (_, id: Int, name: String) in } ``` ### Hook class class and static selector with Swift block ``` _ = try? Test.hook(selector: #selector(Test.classSelector(id:name:)), strategy: .before) { (_, id: Int, name: String) in } ``` ## Requirements - iOS 8.0+ - Swift 4.0-5.x ## Next Steps * Support remove aspect * Improve detail * Support Cocopods install ## Installation #### Carthage Add the following line to your [Cartfile](https://github.com/carthage/carthage) ``` git "https://github.com/woshiccm/Aspect.git" "master" ``` ## Contributors ## Backers ### License Aspect is released under the MIT license. See LICENSE for details.

近期下载者

相关文件


收藏者