views:

1312

answers:

4

I'm just getting started with some iPhone apps, and I'm not finding the API documentation particularly easy to find my way through. I'm currently looking for APIs to do things like

  • turn the 3G network on and off
  • turn Bluetooth on and off
  • set brightness

and so on. Could some kind soul p[oint me to the right documents, or even better point me to some useful overview of the API that is organized in some useful way (as opposed to Apple's organization, which seems to be a combination of whim and when the API was introduced to the world.)

+1  A: 

The reason you can't find these API in the documentation is because they are all private.

Backlight level may be set using a private method on UIApplication:

[(id)[UIApplication sharedApplication] setBacklightLevel:1.0f];
rpetrich
Reminder: Private methods use can cause Apple to reject your software, and can change between releases of the OS with no warning (hence user crashes).
millenomi
This method still exists as of iPhone OS 3.1.2 but does not work anymore. You must use GSEventSetBacklightLevel instead, but note that it is also private.
0xced
A: 

As already mentioned the APIs are private, that's why you're not finding the,. Usage of these private APIs may prevent your app being released on the AppStore.

FeralBob
+3  A: 

Apple's document organization assumes that you start at the beginning and establish a strong basic understanding of the frameworks, patterns and naming conventions. Once you have that, the docs tend to be extremely easy to navigate because you can almost always guess what a thing is called and how it would work if it existed. If you try to jump into the middle and find how to do just this one thing, then they do tend to be confusing because iPhone development is much more about placing your code in the right place than knowing the right thing to call.

As has been noted, these specific things are private. Once you have a good understanding of the iPhone frameworks and design approach, it will tend to also be obvious what is likely private. Anything that messes too much with the hardware, and definitely anything that could prevent the user from receiving a call, is likely to be private. There are a lot of things that Apple will likely make public over time. Modifying the 3G network settings will never be on that list.

And as has been noted, including these features (especially features that modify network settings), can definitely get you removed from the App Store. Screen brightness (as a setting applicable only when your app is running), may be available someday, though I expect it will be a single dim/bright/off setting. Again, Apple is unlikely to allow you to modify the screen brightness in a way that persists outside of your application. Apple will likely never allow developers to do things that can interfere with making phone calls.

If you're having trouble with the docs, I recommend starting with Cocoa Fundamentals. It's not a skimming document. It's definitely a read-ever-word, do some development, and then come back and read it again kind of document. Cocoa is not just Java with a different syntax. It does take some work to understand the patterns. But once you do, it's a really beautiful framework. I discuss a lot of learning Cocoa issues on Cocoaphony if you find yourself looking for more information.

Rob Napier
-1 for taking three paragraphs to say "if you were already familiar with all the documentation you'd know how to find what you want".
Charlie Martin
I'm sorry the length made the answer misleading. A more direct answer if it helps: if you were already familiar with the *patterns*, then the you'd know how to find what you want. You don't need to know all the docs, just the patterns, which Cocoa is extremely consistent to. The links above are intended to point you to where the patterns are.
Rob Napier
+1 for not only saying "if you were already familiar with all the documentation you'd know how to find what you want" but also taking the time to explain WHY these items were private, and thereby cutting off pages and pages of comments about those "Control Freaks in Cupertino."
mmc
-1 for the fanboyish apologist explanations as to why the items are privateI find it totally frustrating that Apple, after getting their own auto-brightness so badly wrong, prevents any one developing an app that gets it right - or even a simple app for toggling system brightness without going to the settings.I used several apps for that on the Palm over the years, including one that automatically adjusted the brightness depending on the time of day - I'm having trouble living without it on my iPhone. A totally justifiable and useful app. Shame on apple for being so controlling here.
Rhubarb
A: 

I can't point you at the code - but would be interested in knowing if you find it - but SBSettings - probably the handiest utility available on jailbroken iphones - manipulates all of these: it has a volume slider and toggle buttons for switching off/on bluetooth and 3g selectively. Google it or install it from Cydia

Let us know if you find out how they do what they do (I've looked in the past but couldnt find source code)

Rhubarb