Skip to content

Instantly share code, notes, and snippets.

View benjaminhallock's full-sized avatar
🎯
Focusing

ben benjaminhallock

🎯
Focusing
View GitHub Profile
-(void)calculateBestAttacker
{
for (Pokemon *p in self.arrayPokemon)
{
if (p.id == self.pokemon1.id) continue;
p.killChance = [self calculateChances:p];
if (self.bestAttacker == nil) self.bestAttacker = p;
else if (self.bestAttacker.killChance < p.killChance) self.bestAttacker = p;
}
@benjaminhallock
benjaminhallock / gist:4afdde555f139593edd9
Created March 22, 2016 16:10
Storing Custom Objects in NSUserDefaults
// View did load
NSData *data = [[NSUserDefaults standardUserDefaults] dataForKey:@"array"];
arrayOfFaceObjects = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:data]];
if (!arrayOfFaceObjects.count)
{
arrayOfImages = [NSMutableArray arrayWithObjects:@"1.png", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"6.jpg", @"8.jpg", @"9.jpg", @"10.jpg", @"11.jpg", @"12.jpg", @"13.jpg", @"14.jpg", @"15.jpg", nil];
//Converts arrayOfImages to arrayOfFaceObjects
@benjaminhallock
benjaminhallock / gist:3a69012d5dec960f2e85
Last active January 30, 2016 07:19
Swift Stats Conversion Playground
//: Playground - noun: a place where people can play
import UIKit
let a : Double = 1.0 / 81.0
var b : Double = 0.0
for var i = 0; i < 729; i++
{
b = a + b
@benjaminhallock
benjaminhallock / AppDelegate.m
Last active June 5, 2016 16:44
How to Parse + Heroku
First, update your Parse Framework https://parse.com/docs/downloads
### Replace the original Appid/ClientKey with....
Parse.initializeWithConfiguration(ParseClientConfiguration(block: { (configuration: ParseMutableClientConfiguration) -> Void in
configuration.applicationId = "myAppId";
configuration.clientKey = "myClientKey";
//need ngrok to host locally, haven't tried it.
// configuration.server = @"http://localhost:1337/parse";
@benjaminhallock
benjaminhallock / gist:46420606d8ef475d535d
Last active December 5, 2017 06:10
How to Paste a GIF (keyboard).
/*
Make sure your using a GIF extension for UIImage... Most UIIMageViews will play it automatically w/ extensions.
I used this one ... https://github.com/mayoff/uiimage-from-animated-gif
This one is more effecient but more code too... https://github.com/Flipboard/FLAnimatedImage
*/
@benjaminhallock
benjaminhallock / gist:b137597ac5ecc2696220
Created October 27, 2015 06:31
CITextDector in iOS9
//
// TextDetectViewController.swift
// iOS9Sampler
//
// Created by Shuichi Tsutsumi on 2015/06/19.
// Copyright © 2015 Shuichi Tsutsumi. All rights reserved.
//
import UIKit