Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When dealing with ivars or private properties of foreign classes, we often find ourselves writing code like this:
We can do a little better if we write an interface for whatever
self.page
is:That cleaned up two lines nicely, but doesn't help us at all with the ivars we need to access, because ivar access requires a class symbol to link against. We could try a little harder, either by using
MSHookIvar
or using%property
to create a property to wrap_layerView
, but then we have to do it again for_actionButtons
, and any other ivar we come across, and so on. And it just gets worse when you have long chains of ivar accesses, which isn't uncommon in complex tweaks.As you can see, this quickly becomes cumbersome. Our code is doomed to be littered with boilerplate everywhere. Isn't this something Logos should be able to do for us? Well, it is. And fortunately, it can!
Proposed solution
This PR adds a slim shorthand syntax for Key-Value Coding. Instead of using
.dot
syntax for properties that require an@interface
, or->
dereferencing ivars, just use.%
to access any private property or ivar. Here's our code from earlier:Isn't that so much better? (Additionally, you can use
.%()
syntax to provide any arbitrary value as the key)What can I do to get this merged?
This is my first "real" contribution to Theos. There's almost no documentation on where anything should go or how the project should be structured, or what the conventions are. I did my best to write neat code and put things where I felt they belonged, but for all I know, I did everything wrong and I've reinvented the wheel with my helper methods (
scanPattern
,scanIdentifier
, etc).And finally, what are your thoughts on this idea in general?