//
// Aspects.h
// Aspects - A delightful, simple library for aspect oriented programming.
//
// Copyright (c) 2014 Peter Steinberger. Licensed under the MIT license.
//
#import <Foundation/Foundation.h>
typedef NS_OPTIONS(NSUInteger, AspectOptions) {
AspectPositionAfter = 0, /// Called after the original implementation (default)
AspectPositionInstead = 1, /// Will replace the original implementation.
AspectPositionBefore = 2, /// Called before the original implementation.
AspectOptionAutomaticRemoval = 1 << 3 /// Will remove the hook after the first execution.
};
/// Opaque Aspect Token that allows to deregister the hook.
@protocol AspectToken <NSObject>
/// Deregisters an aspect.
/// @return YES if deregistration is successful, otherwise NO.
- (BOOL)remove;
@end
/// The AspectInfo protocol is the first parameter of our block syntax.
@protocol AspectInfo <NSObject>
/// The instance that is currently hooked.
- (id)instance;
/// The original invocation of the hooked method.
- (NSInvocation *)originalInvocation;
/// All method arguments, boxed. This is lazily evaluated.
- (NSArray *)arguments;
@end
/**
Aspects uses Objective-C message forwarding to hook into messages. This will create some overhead. Don't add aspects to methods that are called a lot. Aspects is meant for view/controller code that is not called a 1000 times per second.
Adding aspects returns an opaque token which can be used to deregister again. All calls are thread safe.
*/
@interface NSObject (Aspects)
/// Adds a block of code before/instead/after the current `selector` for a specific class.
///
/// @param block Aspects replicates the type signature of the method being hooked.
/// The first parameter will be `id<AspectInfo>`, followed by all parameters of the method.
/// These parameters are optional and will be filled to match the block signature.
/// You can even use an empty block, or one that simple gets `id<AspectInfo>`.
///
/// @note Hooking static methods is not supported.
/// @return A token which allows to later deregister the aspect.
+ (id<AspectToken>)aspect_hookSelector:(SEL)selector
withOptions:(AspectOptions)options
usingBlock:(id)block
error:(NSError **)error;
/// Adds a block of code before/instead/after the current `selector` for a specific instance.
- (id<AspectToken>)aspect_hookSelector:(SEL)selector
withOptions:(AspectOptions)options
usingBlock:(id)block
error:(NSError **)error;
@end
typedef NS_ENUM(NSUInteger, AspectErrorCode) {
AspectErrorSelectorBlacklisted, /// Selectors like release, retain, autorelease are blacklisted.
AspectErrorDoesNotRespondToSelector, /// Selector could not be found.
AspectErrorSelectorDeallocPosition, /// When hooking dealloc, only AspectPositionBefore is allowed.
AspectErrorSelectorAlreadyHookedInClassHierarchy, /// Statically hooking the same method in subclasses is not allowed.
AspectErrorFailedToAllocateClassPair, /// The runtime failed creating a class pair.
AspectErrorMissingBlockSignature, /// The block misses compile time signature info and can't be called.
AspectErrorIncompatibleBlockSignature, /// The block signature does not match the method or is too large.
AspectErrorRemoveObjectAlreadyDeallocated = 100 /// (for removing) The object hooked is already deallocated.
};
extern NSString *const AspectErrorDomain;
没有合适的资源?快使用搜索试试~ 我知道了~
ios-runtime埋点.zip
共108个文件
m:11个
sample:10个
h:9个
需积分: 10 4 下载量 81 浏览量
2019-07-11
18:46:01
上传
评论
收藏 157KB ZIP 举报
温馨提示
runtime实现埋点数据统计,页面停留时间,textfield输入时间,button点击次数。GitHub:https://github.com/YoungLiu666/LYRunTimeLog。顺手给个星,么么哒
资源推荐
资源详情
资源评论
收起资源包目录
ios-runtime埋点.zip (108个子文件)
0706651a9ebcbb6e5af5a776db614128991081 11KB
08f8629d765f2d3b0e37f264316ea7dbb211eb 2KB
129c21e426b8d1ce7fdab48f8a3cb6b0e79279 831B
160994144ac886b9b0ec62d0e751cf6ea0b09e 309B
1d0af00447c35a04e9f4b89879d78caa16b3c9 681B
1d34a042e343fc9f7e9ce5e0cb0c7d6fe05d56 102B
2a8773026d9bcf79deefce28f72c2d3558c48a 638B
2d00f1841a2a9b045b322d4458d08f5d05485f 403B
2f454824dadf582ee0a0e3752c9d9bb67cef70 95B
32205843defe403a6b869172a0870c5f920f0e 264B
3515aceeded13258770bd9d1879225a57422c4 325B
352d595aef4b67eb98b07595935aa0c693f390 225B
386b28c4487d6383f3cee7791bebce49405c13 138B
3949661fa18b4fbc02879e386033ad94c8d91c 895B
3f0ce163c8033a175d27de6a4e96aadc115625 59B
4364089fdc64fe3b81bcd41462dd55edb7a001 57B
48f22ed08cc6ffbc167ddf30a703a494b81b3c 108B
4a4a46ffdced33b4303219ec8474d814a45a3a 72B
524738680109d9f0ca001dad7c9bbf563e898e 523B
5308a937947d0cabf239f7940fb8048b0b941f 131B
59a5846fabe3ed642516015f24c2c5b3eeb33e 650B
5c46ef1470b058228aadf3cc2d6df1782f3262 226B
6c23c43adc88621ce3abfbd1585c8792bd165c 339B
6c72f90461d23cc4291ecb845e6e8157e53a41 100B
6e1bfe23620001f4031ce274ee69c7d20aa964 186B
797f56db6b6849b641f8ff7bbf4b859c7d39d6 866B
7e78c67ff58a8f9d5fdfaf575d6bea3f07a99f 84B
81b21038b14f80b0413f53b41ad2b4a3bc0d3d 249B
82db3143bea796f32f6bd0d8dede4d6d0f6dd6 16KB
861d621c923eb8e3bd1c5aed152b4b5bd09f2d 4KB
95b61a56b9a206a19beebf5d3e96ffbf407bed 179B
9d67080025f3dcd181902134e424b01062717d 147B
9dea9f279b8807014a6e6c089495e86af7a6ea 2KB
a8992f66c62b374a8a99f3e7175bb7c2bb5cae 950B
aa3c34b1f554148be8d7f40168b2abb305cfef 176B
aeb572b4fdd8ce8c79235e962d41d895ee36d9 460B
b1e76c1a47c8e827a9c658b23aff0a1913edc7 61B
b34dd5f81bf62632d32079fbc152604c3d6f81 146B
b51d18f04169081ead924436d12584cf0cbcc3 61B
b74a00da865fa5911c7efef1b2d51344eaa69b 98B
cde70448b662c9af40c9d3d6234fcc8e2fca08 1KB
cf03a65e29b06bcd6699c68cd6e87fe7a21170 180B
COMMIT_EDITMSG 102B
config 405B
d2c80d8893178d7e1f2964085b273959bfdc28 201B
d3195931b6eefb21302bbf804599cc036de0e0 289B
d45378d28422f932a2640de9b786bc571a5385 350B
description 73B
.DS_Store 6KB
.DS_Store 6KB
ef11543d0e86589995b27dd9b649904a838fe7 70B
exclude 240B
f3f97d1b6e9d8d29bb69a88c4d89ca752bd937 807B
f779142c56c980b36a88ebfaf4223d50d523bf 929B
fc0ef1db831c5b2f480a6600f227ced72e5317 269B
fc95a3b490bb4a85b9ab5a762e7cb2528b16f1 746B
FETCH_HEAD 0B
Aspects.h 4KB
LYEventId.h 597B
LYHookUtility.h 375B
LYUserStatist.h 374B
AppDelegate.h 280B
UIViewController+LYSwizzle.h 223B
SecondController.h 220B
ViewController.h 218B
UIControl+LYSwizzle.h 209B
HEAD 247B
HEAD 23B
index 4KB
Contents.json 1KB
Aspects.m 38KB
AppDelegate.m 2KB
ViewController.m 2KB
UIViewController+LYSwizzle.m 2KB
LYUserStatist.m 2KB
UIControl+LYSwizzle.m 2KB
LYRunTimeLogUITests.m 1KB
LYHookUtility.m 944B
LYRunTimeLogTests.m 917B
SecondController.m 497B
main.m 337B
master 247B
master 142B
master 41B
master 41B
project.pbxproj 26KB
Info.plist 1KB
LYFieldType.plist 869B
Info.plist 680B
Info.plist 680B
xcschememanagement.plist 664B
pre-rebase.sample 5KB
update.sample 4KB
pre-commit.sample 2KB
pre-push.sample 1KB
prepare-commit-msg.sample 1KB
commit-msg.sample 896B
pre-receive.sample 544B
applypatch-msg.sample 478B
pre-applypatch.sample 424B
共 108 条
- 1
- 2
资源评论
weixin_39840914
- 粉丝: 435
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功