Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dayitv89/swizzling
Objective C Swizzling : Category method override + inheritance mix concept
https://github.com/dayitv89/swizzling
Last synced: 9 days ago
JSON representation
Objective C Swizzling : Category method override + inheritance mix concept
- Host: GitHub
- URL: https://github.com/dayitv89/swizzling
- Owner: dayitv89
- Created: 2015-05-06T13:33:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-06T14:04:46.000Z (over 9 years ago)
- Last Synced: 2023-03-24T08:42:42.815Z (almost 2 years ago)
- Language: Objective-C
- Size: 1.24 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swizzling
Objective C Swizzling : Category method override + inheritance mix conceptMethod swizzling is the process of changing the implementation of an existing selector. It's a technique made possible by the fact that method invocations in Objective-C can be changed at runtime, by changing how selectors are mapped to underlying functions in a class's dispatch table.
For example, let's say we wanted to track how many times each view controller is presented to a user in an iOS app:
Each view controller could add tracking code to its own implementation of viewDidAppear:, but that would make for a ton of duplicated boilerplate code. Subclassing would be another possibility, but it would require subclassing UIViewController, UITableViewController, UINavigationController, and every other view controller class—an approach that would also suffer from code duplication.
Read it from my blog : http://gauravds.blogspot.in/2015/05/oc-swizzling-category-class-and.html