Results 1 to 1 of 1
11-26-2011, 02:20 PM #1
Everyone has MobileSubstrate installed, and uses it for various tweaks. I would like everyone to learn a bit about how it works, and perhaps you'll gain an appreciation for the things you may take for granted.
Fully understanding what MobileSubstrate does requires grounding in the Objective-C runtime and programming concepts. Of course, I do not expect any of you to have that knowledge, and I will not be overly technical in my writing.
Some Background Info:
The iPhone operating system, along each one of your applications, comprises these things called 'objects'. Objects are an abstraction used by programmers to effectively write programs and to foster reusable code.
Some examples of objects: Every icon on your SpringBoard is an object. So is the "slide to unlock" bar, and the pop-up messages that you see here and there. Those are all objects represented on the screen (we'll call them 'views'). However, there are even more objects behind the scenes. For example, some objects communicate with servers. Others parse XML, store data, or open and write to files. Objects typically do a certain job, which allows programmers to accomplish a task by using combinations of them.
Objects can "own" other objects. For example, the icon objects on your SpringBoard own a label object, which displays the name of the app. See how each object does a specific task and how beneficial that is?
Objects, obviously, can do things. We'll refer to the actions of objects as 'methods'. Ready for an analogy? Objects are to nouns, as methods are to verbs. Got it?
Programmers can tell objects to do certain things. Typically, this is referred to as "calling a method on an object".
An object is a data structure—it stores data in a certain way—that can perform certain actions.
So what does this have to do with MobileSubstrate extensions like QuickReplySMS or SBSettings?
Here we go with analogies again.
Methods are like verbs. Verbs have a defined meaning. The verb "obfuscate" means "to make unclear".
Methods also have "meanings" (we'll call these implementations). An implementation is basically what happens when the method is called. More technical: the code executed when a method is called. In Obj-C specifically, a method name is bound to an implementation (which is function pointer) at runtime
So let's think of methods and their implementations just like verbs and their meanings.
We find the meanings of verbs in a dictionary. For now, let's think of there being a "dictionary" of methods and their implementations also.
MobileSubstrate allows programmers to effectively "change"/"replace" the implementation of methods. So it's just like someone editing a dictionary, resulting in a verb having a new meaning.
The "crazy" part is that the new meaning is in effect whenever anybody uses the verb. The new implementation is used whenever the method is called.
Let's look at SBSettings for example. It's slides onto your screen whenever you swipe the status bar. Well, guess what—there's a method that gets called on some object whenever the status bar gets swiped.
The makers of SBSettings "edited" the the implementation of that method, so their extension could appear on the screen.
Another example is AppLocket. When it's enabled, it prevents applications from being opened. How does that work? It's simple.
Every icon on your SpringBoard is an object, remember? Each one has a "launch" method, which does exactly what you think it does.
When enabled, AppLocket "edits" the implementation of the "launch" method, which results in an annoying pop-up message appearing instead of your app.
I hope this makes sense to anyone reading. I tried to avoid getting overly technical.
Tags for this Thread