Skip to content

Instantly share code, notes, and snippets.

View nfarah86's full-sized avatar

nadine farah nfarah86

View GitHub Profile
@nfarah86
nfarah86 / NFHBeanListViewController.m
Last active May 4, 2016 16:47
NFHBeanListViewController Code Description
- (void)viewDidLoad {
[super viewDidLoad];
self.beansForIdentifiers = [NSMutableDictionary dictionary]; // initialize data structure
self.beanManager = [[PTDBeanManager alloc] initWithDelegate:self]; // create an instance of a Bean Manager
[self performSelector:@selector(scanForBeans) withObject:nil afterDelay:0.5]; //Start scanning for Beans
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Login"
style:UIBarButtonItemStylePlain
@nfarah86
nfarah86 / NFHBeanListViewController.m
Last active May 4, 2016 16:58
Segue to New ViewController
// omitted a ton of code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"showDetail" sender:self];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@nfarah86
nfarah86 / BeanDetailViewController.m
Last active May 5, 2016 01:04
BeanDetailViewController- Connecting to the Bean
@implementation BeanDetailViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Once we load, we will create a singleton and connect to the Bean we selected.
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.beanDetailViewController = self;
@nfarah86
nfarah86 / BeanDetailViewController.m
Created May 5, 2016 01:11
Get Serial Data from the Bean
// omitted tons of code
-(void)bean:(PTDBean*)bean serialDataReceived:(NSData*)data
{
NSString *receivedMessage=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding];
NSLog (@"%@ this works", receivedMessage);
// omitted code
}
// omitted code
@nfarah86
nfarah86 / NFHLocationManager.m
Created May 5, 2016 03:23
Initialize an Instance of CLLocationManager
// omitted code
- (instancetype)init
{
self = [super init]; // inital. self; overrid. init.
if (self) {
_locationManager = [[CLLocationManager alloc]init];
}
return self;
}
// omitted code
// omitted code
- (void)startStandardUpdates
{
if (![CLLocationManager locationServicesEnabled]) {
NSLog(@"Location services are not available (or are disabled for this app).");
}
else {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
@nfarah86
nfarah86 / NFHBeanListViewController.m
Last active May 5, 2016 03:41
Set Location Details
// omitted code
- (void)startStandardUpdates{
if (![CLLocationManager locationServicesEnabled]) {
NSLog(@"Location services are not available (or are disabled for this app).");
}
else {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
self.locationManager.distanceFilter = 0;
@nfarah86
nfarah86 / BeanDetailViewController.m
Created May 6, 2016 03:14
Update the UI with Current Latitude and Longitude Location
// omitted code
- (void)updateInterfaceWithLocation:(CLLocation *)lastLocation {
// we update the UILabel with the longitude and latitude values
self.latitude.text = [NSString stringWithFormat:@"%f",lastLocation.coordinate.latitude];
self.longitude.text = [NSString stringWithFormat:@"%f",lastLocation.coordinate.longitude];
}
// omitted code
- (IBAction)buttonPress:(id)sender {
CLLocation *lastLocation = [NFHLocationManager sharedLocationManager].lastLocation;
@nfarah86
nfarah86 / BeanDetailViewController.m
Last active May 6, 2016 03:18
Get the User's Latitude and Longitude Coordinates Every 10 seconds
// omitted code
- (void)viewDidLoad
{
// omitted code
self.timer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(timerDidFire:) userInfo:nil repeats:YES];
}
-(void)timerDidFire: (id)sender
{
NFHLocationManager *locationManager = [NFHLocationManager sharedLocationManager];
@nfarah86
nfarah86 / login.html
Created May 6, 2016 22:03
Check to See if the User is in the Database
// omitted code
<form method="POST" class="navbar-form nav-center pull-right" action="/process_login">
<div class="form-group">
<input type="text" placeholder="Username" class="form-control" name="user_name">
<input type="hidden" name="action" value="signIn">
</div>
<div class="form-group">