From iPhone Development Wiki
Jump to: navigation, search

Plankets are widgets for PogoPlank and are developed using ObjC. They are currently only in developer alpha testing, but will be released soon as a private beta. Plankets began in version 2.0 with the idea of making widgets available on the iPhoneOS. Plankets come with an API that makes various MobileSubstrate hooks available at the call of a simple function, thereby making Plankets very easy for developers to create.


The Planket API comes with 3 headers, Planket.h PlankApp.h and PlankAPI.h, each serving a separate purpose. PlankAPI.h comes with several static functions for interacting with other Plankets. PlankApp.h is used to create an Application, similar to SBApplicationIcon. Planket.h is by far the most important header. This allows you to extend the Planket class and thereby create your own Planket.

Example code

Here is a very simple Planket using a PlankApp and a few PlankAPI functions:


#ifndef _MYPLANKET_H_
#define _MYPLANKET_H_
#import "Planket.h"
#import "PlankAPI.h"
#import "PlankApp.h"

@interface MyPlanket : Planket {
	PlankApp *app;

- (id)initWithSize:(CGRect)size;
- (void)onLoad;



#import "MyPlanket.h"
#import <UIKit/UIColor.h>

extern "C" Planket *PlanketInit(CGRect size) {
	return (Planket *)[[MyPlanket alloc] initWithSize:size];

@implementation MyPlanket
	- (id)initWithSize:(CGRect)size {
		if (self = [super initWithSize:size]) {
			[self setBackgroundColor: [UIColor blueColor]];
			app = [[PlankApp alloc] initWithBundle:@""];
			[app setFrame:CGRectMake(20, 60, 48, 48)]; //Notice we set the frame AFTER initWithBundle. This allows PlankApp to set the background as the image associated with the bundle ID
			[app setLaunchOnTouch: YES]; //This is the default action anyway.. No need to set it. Just for information purposes :)
			[self addSubview:app];
			return self;
		} else {
			PLog(@"MyPlanket: Error! Failed to create"); //PlankAPI Call

	- (void)onLoad {
		[PlankAPI hideOtherPlankets:self]; //When we load.. Show only ourselves.

Plankets must have the extern C function PlanketInit and be linked with -lplank to ensure they are linked to libplank.dylib (included in PogoPlank).