Skip to content

Instantly share code, notes, and snippets.

View armadsen's full-sized avatar

Andrew Madsen armadsen

View GitHub Profile
@armadsen
armadsen / CGMutablePathRef_NSInvocation.m
Last active August 29, 2015 13:56
Simple test program demonstrating use of NSInvocation to get CGMutablePathRef property by name
/* Compile and run like so:
$> clang CGMutablePathRef_NSInvocation.m -ObjC -std=c99 -fobjc-arc -framework Foundation -framework CoreGraphics
$> ./a.out
*/
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
@interface TestClass : NSObject
/* Written for answer to http://stackoverflow.com/questions/23700556/getting-a-date-from-string-objective-c/23700701
Compile and run like so:
$> clang DateFormatterExample.m -ObjC -std=c99 -fobjc-arc -framework Foundation
$> ./a.out
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
@armadsen
armadsen / SceneKitCheatSheet.m
Last active October 28, 2021 08:06
Cheat sheet for SceneKit learning app (Objective-C)
// Configure the Scene View
self.sceneView.backgroundColor = [UIColor darkGrayColor];
// Create the scene
SCNScene *scene = [SCNScene scene];
@armadsen
armadsen / Person.m
Created February 23, 2015 02:09
Person.m for DevMountain Lesson 13
// For .h:
@interface Person : NSObject
@property (nonatomic, strong) NSString *imageName;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *phoneNumber;
@property (nonatomic, strong) NSString *job;
- (id)initWithDictionary:(NSDictionary *)dictionary;
@armadsen
armadsen / PersonController.m
Created February 23, 2015 02:10
PersonController for DevMountain Lesson 13
// For PersonController.h:
#import "Person.h"
@interface PersonController : NSObject
@property (nonatomic, strong, readonly) NSArray *personList;
+ (PersonController *)sharedInstance;
@armadsen
armadsen / FakePeople
Last active August 29, 2015 14:15
Fake People
+ (NSArray *)allTheFakePeople {
return @[
@{imageNameKey: @"1",
nameKey: @"Some Dude",
phoneNumberKey: @"888-888-8888",
jobKey: @"Garbage Collection"},
@{imageNameKey: @"2",
nameKey: @"Chris Sacca",
phoneNumberKey: @"920-558-1033",
@armadsen
armadsen / Lesson17.m
Last active August 29, 2015 14:16
DevMountain Lesson 17 (Submodules, AVFoundation, CocoaPods) copy/paste blocks
git submodule add https://github.com/AFNetworking/AFNetworking.git External/AFNetworking
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.timeapi.org/utc/now"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, NSData *responseObject) {
NSString *response = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"response: %@", response);
@armadsen
armadsen / EventCellDrawRect.m
Created March 16, 2015 14:09
-[EventCell drawRect] for CustomDesignedAgenda (DevMountain Lesson 25 - Custom Interfaces)
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
UIColor *color = [UIColor colorWithWhite:1.0 alpha:0.2];
[color setFill];
[color setStroke];
// Draw stripe on right
CGRect sideLineRect = CGRectMake(CGRectGetMidX(self.marker.frame) - 1.5,
@armadsen
armadsen / responds.m
Last active August 29, 2015 14:17
Tiny demo of -respondsToSelector:
/* Compile and run with:
$> clang responds.m -ObjC -std=c99 -framework Foundation
$> ./a.out
*/
#import <Foundation/Foundation.h>
@interface Foo : NSObject
- (int)bar;
@end
@armadsen
armadsen / AdvancedArduino.md
Last active August 29, 2015 14:20
Deckset Markdown file for my presentation, "Arduino and iOS" at CocoaHeads SLC, May 5, 2015.

build-lists: true autoscale: true

#Advanced Arduino ###(or Arduino and iOS)

####Andrew Madsen ####CocoaHeads SLC - May 5, 2015