René's URL Explorer Experiment


Title: RunTime 之方法交换 · Issue #4 · aTreey/aTreey.github.io · GitHub

Open Graph Title: RunTime 之方法交换 · Issue #4 · aTreey/aTreey.github.io

X Title: RunTime 之方法交换 · Issue #4 · aTreey/aTreey.github.io

Description: 以前只是看到过运行时相关的资料,现在项目中依然在用UIWebView 最近打算给WebView 加一个假的进度条,所以打算通过使用RunTime给UIWebView 增加分类关联属性和方法的方式实现 方法交换 class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name) 获取cls类的实例方法, cls 要获取实例方法的相关类, name 需要获取类的实例方法名称 class_getClassMethod...

Open Graph Description: 以前只是看到过运行时相关的资料,现在项目中依然在用UIWebView 最近打算给WebView 加一个假的进度条,所以打算通过使用RunTime给UIWebView 增加分类关联属性和方法的方式实现 方法交换 class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name) 获取cls类的实例方法, cls 要获取实例方法的相关类...

X Description: 以前只是看到过运行时相关的资料,现在项目中依然在用UIWebView 最近打算给WebView 加一个假的进度条,所以打算通过使用RunTime给UIWebView 增加分类关联属性和方法的方式实现 方法交换 class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name) 获取cls类的实例方法, cls 要获取实例方法的相关类...

Opengraph URL: https://github.com/aTreey/aTreey.github.io/issues/4

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RunTime 之方法交换","articleBody":"以前只是看到过运行时相关的资料,现在项目中依然在用`UIWebView` 最近打算给`WebView` 加一个假的进度条,所以打算通过使用`RunTime`给`UIWebView`  增加分类关联属性和方法的方式实现\r\n## 方法交换\r\n\r\n- `class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name)` 获取`cls`类的实例方法,\r\n  -  `cls` 要获取实例方法的相关类,\r\n  - `name` 需要获取类的实例方法名称\r\n\r\n-  `class_getClassMethod(Class _Nullable cls, SEL _Nonnull name)`  获取`cls`类的类方法,\r\n   - `cls` 要获取实例方法的相关类,\r\n   - `name` 需要获取类的类方法名称\r\n\r\n-  `method_getImplementation`  获取一个方法的`IMP`(方法的实现),具体是指`implement`\r\n\r\n-  `method_getTypeEncoding ` 获取一个方法实现的Type字符串,包括参数类型和返回值类型\r\n\r\n-  `class_addMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, \r\n                const char * _Nullable types)`  添加一个新的方法,\r\n    - `cls`: 需要被添加的类\r\n    -  `SEL`:  要被添加的方法 例如:`@selector(webViewDidFinishLoad:)`\r\n    -   `IMP`:  添加的方法实现地址,例如:`(IMP)my_webViewDidFinishLoad`\r\n    - `types`: 方法实现的Type字符串,包括参数类型和返回值类型\r\n\r\n\r\n     \u003e        无参无返回值: \"V@:\"\r\n     \u003e        有参无返回值:  \"i@:\"  返回值为`int`类型\r\n     \u003e        有参有返回值: \"i@:@\"  返回值为`int`类型,有一个参数\r\n\r\n \r\n   - 返回值为`BOOl` \r\n   - 保证即便originalSelector只在父类中实现,也能达到Method Swizzling的目的, 比如一个方法只是在父类中实现而在子类中未实现,`class_addMethod`就会执行返回值为`YES`以达到方法替换,\r\n   - 如果子类本身实现了这个方法,返回值为NO,然后我们只需要直接执行`class_replaceMethod`方法就可以达到目的\r\n\r\n-  `class_replaceMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, \r\n                    const char * _Nullable types)`   替换类中添加成功的方法的实现, 如果该方法不存在就会添加该方法, 覆盖执行`class_addMethod`然后再替换换两个方法实现\r\n\r\n-  `method_exchangeImplementations(Method _Nonnull m1, Method _Nonnull m2) `  交换两个已经存在的方法实现\r\n\r\n[交换方法代码示例参考](http://nshipster.com/method-swizzling/)\r\n\r\n\r\n## 给分类关联属性和方法\r\n\r\n- `objc_getAssociatedObject(id _Nonnull object, const void * _Nonnull key) `  给get方法关联值,返回与给定键的特定对象关联的值\r\n\r\n-  `objc_setAssociatedObject(id _Nonnull object, const void * _Nonnull key,\r\n                         id _Nullable value, objc_AssociationPolicy policy)`  给`set`方法关联值,\r\n   - object:要关联的**源对象**\r\n   - key:关联时标记是哪一个属性的key,用于区分关联的多个属性,可以用 `_cmd`代替, `_cmd` 在Objective-C的方法中表示当前方法的selector,正如同self表示当前方法调用的对象实例一样,每个方法都是不一样的\r\n   - value: 关联的对象\r\n   - policy:关联策略\r\n\r\n","author":{"url":"https://github.com/aTreey","@type":"Person","name":"aTreey"},"datePublished":"2018-06-05T15:47:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/4/aTreey.github.io/issues/4"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ed1b1544-12a9-202f-b32a-a870db9a05c6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9D54:0B26:912110:C6FB2D:6A570846
html-safe-noncede75fee9cc8d5f78d44a2a0b4e2cfbfd532bd88451581aa045b6e706a2689dca
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDU0OjBCMjY6OTEyMTEwOkM2RkIyRDo2QTU3MDg0NiIsInZpc2l0b3JfaWQiOiIzNjIzODA5ODMwOTMzMTcwMjQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc94ae82a95653132bdd4293a2b7fc0d686597b7912ebd557946275a6d6fee670
hovercard-subject-tagissue:329517842
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/aTreey/aTreey.github.io/4/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1108099b5abda841c32f3676214c7c0a797a1864ce84f8e0b415165e81dba0b7/aTreey/aTreey.github.io/issues/4
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1108099b5abda841c32f3676214c7c0a797a1864ce84f8e0b415165e81dba0b7/aTreey/aTreey.github.io/issues/4
og:image:alt以前只是看到过运行时相关的资料,现在项目中依然在用UIWebView 最近打算给WebView 加一个假的进度条,所以打算通过使用RunTime给UIWebView 增加分类关联属性和方法的方式实现 方法交换 class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name) 获取cls类的实例方法, cls 要获取实例方法的相关类...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameaTreey
hostnamegithub.com
expected-hostnamegithub.com
None4eb29e5f807bd95e41196adfbc6d28f9af12d89830d8b684f3e871774ddff2fc
turbo-cache-controlno-preview
go-importgithub.com/aTreey/aTreey.github.io git https://github.com/aTreey/aTreey.github.io.git
octolytics-dimension-user_id14048652
octolytics-dimension-user_loginaTreey
octolytics-dimension-repository_id125624771
octolytics-dimension-repository_nwoaTreey/aTreey.github.io
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id125624771
octolytics-dimension-repository_network_root_nwoaTreey/aTreey.github.io
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb056788a129fb0194b61f2ebb4c43f6a9f4dfd27
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/aTreey/aTreey.github.io/issues/4#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FaTreey%2FaTreey.github.io%2Fissues%2F4
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FaTreey%2FaTreey.github.io%2Fissues%2F4
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=aTreey%2FaTreey.github.io
Reloadhttps://github.com/aTreey/aTreey.github.io/issues/4
Reloadhttps://github.com/aTreey/aTreey.github.io/issues/4
Reloadhttps://github.com/aTreey/aTreey.github.io/issues/4
aTreey https://github.com/aTreey
aTreey.github.iohttps://github.com/aTreey/aTreey.github.io
Notifications https://github.com/login?return_to=%2FaTreey%2FaTreey.github.io
Fork 1 https://github.com/login?return_to=%2FaTreey%2FaTreey.github.io
Star 2 https://github.com/login?return_to=%2FaTreey%2FaTreey.github.io
Code https://github.com/aTreey/aTreey.github.io
Issues 7 https://github.com/aTreey/aTreey.github.io/issues
Pull requests 2 https://github.com/aTreey/aTreey.github.io/pulls
Actions https://github.com/aTreey/aTreey.github.io/actions
Projects https://github.com/aTreey/aTreey.github.io/projects
Security and quality 0 https://github.com/aTreey/aTreey.github.io/security
Insights https://github.com/aTreey/aTreey.github.io/pulse
Code https://github.com/aTreey/aTreey.github.io
Issues https://github.com/aTreey/aTreey.github.io/issues
Pull requests https://github.com/aTreey/aTreey.github.io/pulls
Actions https://github.com/aTreey/aTreey.github.io/actions
Projects https://github.com/aTreey/aTreey.github.io/projects
Security and quality https://github.com/aTreey/aTreey.github.io/security
Insights https://github.com/aTreey/aTreey.github.io/pulse
RunTime 之方法交换https://github.com/aTreey/aTreey.github.io/issues/4#top
RunTimeExtra attention is neededhttps://github.com/aTreey/aTreey.github.io/issues?q=state%3Aopen%20label%3A%22RunTime%22
https://github.com/aTreey
aTreeyhttps://github.com/aTreey
on Jun 5, 2018https://github.com/aTreey/aTreey.github.io/issues/4#issue-329517842
交换方法代码示例参考http://nshipster.com/method-swizzling/
RunTimeExtra attention is neededhttps://github.com/aTreey/aTreey.github.io/issues?q=state%3Aopen%20label%3A%22RunTime%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.