The state of toggles on iOS
Toggling things like wifi or bluetooth on and off quickly and conveniently is a feature that has been added to lots of apps and tweaks since very early on since iOS was first jailbroken.
In the past
This trend started off with things like Bossprefs which managed various settings on the device but was a stand alone app and didn’t have much flexibility:

Then you have SBSettings. SBSettings got lots of attention and quickly became one of the default things people installed on their jailbroken devices once they finished jailbreaking. And of cause it has it’s own API so other developers could have it control their things, such as SSH or UserAgentFaker.

The problem with SBSettings API is it was designed quite early in iOS’s history and so isn’t designed very natively and could be much better (more on that later). It has it’s advantages though, isn’t quite simple. Each toggle has a dylib with a few simple C functions. SBSettings opens them and calls the functions to make things happen or check it’s state. It also includes some more advanced options like presenting extra windows to show things like a list of processes running or a slider for the brightness. As a sign of it’s age it must respring to reload it’s settings. When it was designed that was the norm and having a tweak which could adapt to settings on the fly without resrpinging would be a killer feature.
Now
iOS and ObjectiveC has moved on quite a bit now and is much more advanced and more refined then it was. SBSettings was good but after iOS 4 I stopped using it. This was mostly down to notification centre taking over as the “above” window on my device. Having 2 windows that drop down form the top of the screen as a control centre for my device each activated under different circumstances just feels wrong, so I don’t us it anymore (and it although quite a few people still use it, it isn’t as popular as it once was).
NCSettings has mostly replaced it for me. SBSettings has a mode to run inside notification centre but it just doesn’t fit well. It has been adapted quite well, but it and it’s toggles weren’t designed for that purpose. NCSettings by comparison was designed from the start to run in the notification centre and fits in very well with a minimal stripped back design.

And now everything offers some basic controls and toggles. Deck is an example of something like NCSettings designed to do just that. However, lots of tweaks now offer some sort of toggles, Auxo for example extends the simple mute/orientation lock toggle in the switcher to a more general control of the devices basic features. The problem with all these things is they are limited to what you can convince the developer to add support for and anything like SSH or your own add-on which is a separate package and my not be installed on everyones devices is going to be a hard sale to get added. In short none of them have an API and there’s defiantly not a unified API among them. The closest I’ve seen is a tweak using SBSettings API for itself.
Now that I’ve briefly outlined how toggles on iOS currently are I’m going to outline how I think they should, or rather could, be in another blog post.
I wish I could take credit for this but I can’t. Got this from an arstechnica.com forum posting from way back in June of 2010.
The forum poster’s moniker is The Real Blastdoor. Please join me in thanking him for this, because it is absolutely pure gold. Additionally, each and every word is true.
The Apple haters’ stages of grief go something like this:
- Predict failure of new Apple product
- Attribute early success of new Apple product to rabid fanbois affected by the reality distortion field
- Attribute longer term success of product to stupidity of consumers
- Purchase previously scorned product for stupid relatives so they stop bothering you to help support the open source version of Apple product sold by Super Lucky Technology Extreme Inc. that you convinced them to buy
- Purchase previously scorned product for yourself just to see what all the fuss is about
- Admit that you now own and use the product, but complain about the product’s lack of SD card slot on random Internet forum
- Forget prior criticism of product, claim that it was revolutionary and an example of how Apple used to be really innovative, but has now lost its edge
Rinse and repeat
Author: The Real Blastdoor on Tue Jun 01, 2010 8:05 am
So true!
Recreating iOS6’s remote views for iOS 5
If you haven’t already read @olebegemann’s blog post about _UIRemoteView’s and remote view controllers new in iOS 6 then please do so now and come back to this after you have finished it.
http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/
When I first read this post about iOS 6 and _UIRemoteView’s which allowed apple to move things like email into different processes and still display them as if they where in the app there was one point I that caught my attention more then it would most peoples.
<_UIRemoteView: 0x1e05c300; frame = (0 0; 320 480); transform = [0.5, -0, 0, 0.5, -0, 0]; userInteractionEnabled = NO; layer = <CALayerHost: 0x1e05c460»
CALayerHost, the instant I sure that I thought, “wow, Apple finally put it to good use’. From my experiments with CardSwitcher I have come across CALayerHost’s before. They are actually how CardSwitcher’s live views work. More then displaying part of an app, however, they also allow interaction through to that app (although that is buggy iOS 5, haven’t tested 6 yet). For CardSwitcher to use them as live views into apps it actually has to block interaction, if you remove that you get this http://www.youtube.com/watch?v=1D1NyXITjI0.
Not all of this is applicable to Cocoa and Cocoa Touch development (good luck not using the heap), but so much of it is. I recommend reading the whole thing, but here are some highlights translated to Objective-C and its environs:
Rule 2 (routine checking)
- All code shall always be compiled with all compiler warnings enabled at the highest warning level available, with no errors or warnings resulting.
- All code shall further be verified with a JPL approved state-of-the-art static source code analyzer, with no errors or warnings resulting. …
… The rule of zero warnings applies even in cases where the compiler or the static analyzer gives an erroneous warning. If the compiler or the static analyzer gets confused, the code causing the confusion should be rewritten so that it becomes more clearly valid. Many developers have been caught in the assumption that a tool warning was false, only to realize much later that the message was in fact valid for less obvious reasons. …
Raise your hand if you’ve heard the sentence “it’s a false positive, ignore it” before.
Rule 7 (thread safety)
- Task synchronization shall not be performed through the use of task delays.
Specifically the use of task delays has been the cause of race conditions that have jeopardized the safety of spacecraft. The use of a task delay for task synchronization requires a guess of how long certain actions will take. If the guess is wrong, havoc, including deadlock, can be the result.
In Cocoa/Cocoa Touch, this means that you should avoid using
performSelector:withObject:afterDelay:(orsleep,usleep,nanosleep,+[NSThread sleepForTimeInterval:],-[NSRunLoop runUntilDate:], etc.) to try to “fix” a bug. Occasionally it fixes something. Often it breaks something else. And often it doesn’t fix the original problem.For instance, an area of memory above the stack limit allocated to each task should be reserved as a safety margin, and filled with a fixed and uncommon bit-pattern.
On the Mac, you can do this with the malloc environment variables and/or GuardMalloc.
Rule 15 (checking parameter values)
- The validity of function parameters shall be checked at the start of each public function.
- The validity of function parameters to other functions shall be checked by either the function called or by the calling function.
Foundation provides
NSParameterAssertfor this purpose. In Objective-C, what this document calls a “public function” will generally be a method you’ve declared in the@interfacein your class’s header file, whereas other functions are methods that you haven’t declared there. In other words, the class should trust itself to give itself good input, but not other classes.Test cases are a good way to exercise these assertions: Intentionally send messages to the class, or instances of it, with bad input, knowing that if the assertion fails (an exception is thrown), the test will fail. If that doesn’t happen, it may indicate that the bad input would spread deeper into the class/object in a real run, which could be causing a problem your users are seeing (or will see).
Rule 25
- Functions should be no longer than 60 lines of text and define no more than 6 parameters.
This is especially true of C functions, since there’s nothing to label the parameters at the call site, but it’s a good rule for Objective-C, as well. If a single message contains more than, let’s say, 4 arguments, I recommend building an object around that message instead. Turn the arguments, particularly any that are optional, into properties.
Such objects will probably help you clarify other aspects of your design while you’re at it.
How to code to space craft levels of safety.

