Difference between revisions of "SpringBoard"

From iPhone Development Wiki
Jump to: navigation, search
m (Was incorrect about the class of the reference in one situation)
Line 1: Line 1:
{{about|the Objective-C class|the application|SpringBoard.app}}
+
The NSAutoreleasePool class is a thin wrapper around the '''NSPushAutoreleasePool''' and '''NSPopAutoreleasePool''' functions.
  
[[SpringBoard]] is the singleton class that manages the {{applink|SpringBoard}} application.
+
<source lang="objc">
 +
#ifdef __cplusplus
 +
extern "C" {
 +
#endif
 +
void *NSPushAutoreleasePool(NSUInteger capacity);
 +
void NSPopAutoreleasePool(void* token);
 +
#ifdef __cplusplus
 +
}
 +
#endif
 +
</source>
  
== Monitoring Orientation of Top App ==
+
Example:
Whenever the orientation of the top application is changed, <tt>-[SpringBoard noteUIOrientationChanged:display:]</tt> is called. Therefore, you can hook this method to be notified of the event.
 
  
You can also hook SpringBoard's <tt>-(void)noteInterfaceOrientationChanged:(int)arg1 duration:(float)arg2</tt>
+
<source lang="objc">
 +
static void MyMethod()
 +
{
 +
    void *pool = NSPushAutoreleasePool(0);
 +
    [[[NSObject alloc] init] autorelease];
 +
    NSPopAutoreleasePool(pool);
 +
}
 +
</source>
  
== Orientation ==
+
The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation.
  
<tt>activeInterfaceOrientation</tt> shows present orientation 
+
{{occlass|library=Foundation.framework}}
 
 
<tt>interfaceOrientationForCurrentDeviceOrientation</tt> shows the device orientation 
 
 
 
Q: When will these be different? 
 
 
 
A: If you have the device locked in portrait but a game plays in landscape these values will be different. activeInterfaceOrientation will be in landscape while interfaceOrientationForCurrentDeviceOrientation will still be in the locked portrait.
 
 
 
== Sending messages to SpringBoard ==
 
Because SpringBoard inherits from UIApplication, you can send messages to it as follows: <tt>[[SpringBoard sharedApplication] aMethod]</tt>
 
 
 
== Getting the top SBApplication ==
 
A reference to the top SBApplication may be obtained by using the following method: <tt>[[SpringBoard sharedApplication] _accessibilityFrontMostApplication]</tt>.
 
 
 
== Monitoring when a new app or the homescreen is displayed ==
 
 
 
Whenever a different app is displayed, <tt>frontDisplayDidChange:(id *)newDisplay</tt> is called. <tt>newDisplay</tt> is a reference to the SBApplication of the displayed app if the app was switched to, or it is nil if the homescreen is now showing. However, in some situations, it may be a reference to a <tt>UIViewController</tt>. For example, when the lockscreen is shown, <tt>newDisplay</tt> references an instance of <tt>SBLockScreenViewController</tt>. Make sure you account this in your tweak.
 
 
 
== References ==
 
* Header: http://github.com/kennytm/iphone-private-frameworks/blob/master/SpringBoard/SpringBoard-Class.h
 
 
 
{{occlass|library=SpringBoard.app|navbox=1}}
 

Revision as of 09:40, 2 February 2017

The NSAutoreleasePool class is a thin wrapper around the NSPushAutoreleasePool and NSPopAutoreleasePool functions.

#ifdef __cplusplus
extern "C" {
#endif
void *NSPushAutoreleasePool(NSUInteger capacity);
void NSPopAutoreleasePool(void* token);
#ifdef __cplusplus
}
#endif

Example:

static void MyMethod()
{
    void *pool = NSPushAutoreleasePool(0);
    [[[NSObject alloc] init] autorelease];
    NSPopAutoreleasePool(pool);
}

The "capacity" argument of NSPushAutoreleasePool only serves as a hint. It is unused in the current implementation.