-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created skeleton iPhone app project in Xcode.
- Loading branch information
0 parents
commit 9054af0
Showing
10 changed files
with
1,563 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// MarquetteAppDelegate.h | ||
// Marquette | ||
// | ||
// Created by Nicholas Humfrey on 15/01/2012. | ||
// Copyright 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class MarquetteViewController; | ||
|
||
@interface MarquetteAppDelegate : NSObject <UIApplicationDelegate> { | ||
UIWindow *window; | ||
MarquetteViewController *viewController; | ||
struct mosquitto *mosq; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIWindow *window; | ||
@property (nonatomic, retain) IBOutlet MarquetteViewController *viewController; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// | ||
// MarquetteAppDelegate.m | ||
// Marquette | ||
// | ||
// Created by Nicholas Humfrey on 15/01/2012. | ||
// Copyright 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "MarquetteAppDelegate.h" | ||
#import "MarquetteViewController.h" | ||
|
||
#include "mosquitto.h" | ||
|
||
|
||
@implementation MarquetteAppDelegate | ||
|
||
@synthesize window; | ||
@synthesize viewController; | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Application lifecycle | ||
|
||
- (id) init | ||
{ | ||
self = [super init]; | ||
if (self != nil) | ||
{ | ||
// Initialise the mosquitto library | ||
mosquitto_lib_init(); | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
|
||
// Override point for customization after application launch. | ||
|
||
// Set the view controller as the window's root view controller and display. | ||
self.window.rootViewController = self.viewController; | ||
[self.window makeKeyAndVisible]; | ||
|
||
mosq = mosquitto_new("marquette_iphone", NULL); | ||
|
||
// FIXME: only if compiled in debug mode? | ||
mosquitto_log_init(mosq, MOSQ_LOG_ALL, MOSQ_LOG_STDERR); | ||
|
||
return YES; | ||
} | ||
|
||
|
||
- (void)applicationWillResignActive:(UIApplication *)application { | ||
/* | ||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
*/ | ||
mosquitto_disconnect(mosq); | ||
} | ||
|
||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application { | ||
/* | ||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits. | ||
*/ | ||
mosquitto_disconnect(mosq); | ||
} | ||
|
||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application { | ||
/* | ||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. | ||
*/ | ||
mosquitto_reconnect(mosq); | ||
} | ||
|
||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
/* | ||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
*/ | ||
} | ||
|
||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
/* | ||
Called when the application is about to terminate. | ||
See also applicationDidEnterBackground:. | ||
*/ | ||
} | ||
|
||
|
||
#pragma mark - | ||
#pragma mark Memory management | ||
|
||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { | ||
/* | ||
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. | ||
*/ | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
[viewController release]; | ||
[window release]; | ||
|
||
// Free resources used by the mosquitto library | ||
mosquitto_destroy(mosq); | ||
mosquitto_lib_cleanup(); | ||
|
||
[super dealloc]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// MarquetteViewController.h | ||
// Marquette | ||
// | ||
// Created by Nicholas Humfrey on 15/01/2012. | ||
// Copyright 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface MarquetteViewController : UIViewController { | ||
UISwitch *ledSwitch; | ||
|
||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UISwitch *ledSwitch; | ||
|
||
- (IBAction) ledSwitchAction:(id)sender; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// MarquetteViewController.m | ||
// Marquette | ||
// | ||
// Created by Nicholas Humfrey on 15/01/2012. | ||
// Copyright 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "MarquetteViewController.h" | ||
|
||
@implementation MarquetteViewController | ||
|
||
@synthesize ledSwitch; | ||
|
||
|
||
/* | ||
// The designated initializer. Override to perform setup that is required before the view is loaded. | ||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | ||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | ||
if (self) { | ||
// Custom initialization | ||
} | ||
return self; | ||
} | ||
*/ | ||
|
||
/* | ||
// Implement loadView to create a view hierarchy programmatically, without using a nib. | ||
- (void)loadView { | ||
} | ||
*/ | ||
|
||
|
||
/* | ||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
} | ||
*/ | ||
|
||
|
||
/* | ||
// Override to allow orientations other than the default portrait orientation. | ||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | ||
// Return YES for supported orientations | ||
return (interfaceOrientation == UIInterfaceOrientationPortrait); | ||
} | ||
*/ | ||
|
||
- (void)didReceiveMemoryWarning { | ||
// Releases the view if it doesn't have a superview. | ||
[super didReceiveMemoryWarning]; | ||
|
||
// Release any cached data, images, etc that aren't in use. | ||
} | ||
|
||
- (void)viewDidUnload { | ||
// Release any retained subviews of the main view. | ||
// e.g. self.myOutlet = nil; | ||
} | ||
|
||
- (IBAction) ledSwitchAction:(id)sender { | ||
if ([sender isOn]) { | ||
NSLog(@"LED On"); | ||
} | ||
else { | ||
NSLog(@"LED Off"); | ||
} | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
[super dealloc]; | ||
} | ||
|
||
@end |
Oops, something went wrong.