Skip to content

Instantly share code, notes, and snippets.

@jjones3535a
Created October 29, 2012 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjones3535a/3976969 to your computer and use it in GitHub Desktop.
Save jjones3535a/3976969 to your computer and use it in GitHub Desktop.
Appcelerator custom module
// This is in ComExampleTestModule.m
#import "ComExampleTestModule.h"
#import "TiBase.h"
#import "TiHost.h"
#import "TiUtils.h"
@implementation ComExampleTestModule
#pragma mark Internal
// this is generated for your module, please do not change it
-(id)moduleGUID
{
return @"xxxxxxx-1234-abcd-aaaa-aefefefefefe";
}
// this is generated for your module, please do not change it
-(NSString*)moduleId
{
return @"com.example.test";
}
#pragma mark Lifecycle
-(void)startup
{
// this method is called when the module is first loaded
// you *must* call the superclass
[super startup];
NSLog(@"[INFO] MODULE-EXAMPLE-Test %@ loaded",self);
}
-(void)shutdown:(id)sender
{
// this method is called when the module is being unloaded
// typically this is during shutdown. make sure you don't do too
// much processing here or the app will be quit forceably
// you *must* call the superclass
[super shutdown:sender];
}
#pragma mark Cleanup
-(void)dealloc
{
// release any resources that have been retained by the module
[super dealloc];
}
#pragma mark Internal Memory Management
-(void)didReceiveMemoryWarning:(NSNotification*)notification
{
// optionally release any resources that can be dynamically
// reloaded once memory is available - such as caches
[super didReceiveMemoryWarning:notification];
}
#pragma mark Listener Notifications
-(void)_listenerAdded:(NSString *)type count:(int)count
{
if (count == 1 && [type isEqualToString:@"my_event"])
{
// the first (of potentially many) listener is being added
// for event named 'my_event'
}
}
-(void)_listenerRemoved:(NSString *)type count:(int)count
{
if (count == 0 && [type isEqualToString:@"my_event"])
{
// the last listener called for event named 'my_event' has
// been removed, we can optionally clean up any resources
// since no body is listening at this point for that event
}
}
#pragma Public APIs
-(void)sayHello
{
//ENSURE_UI_THREAD_1_ARG(args);
NSLog(@"[INFO] Hello..............................................");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment