Skip to content

Instantly share code, notes, and snippets.

View armadsen's full-sized avatar

Andrew Madsen armadsen

View GitHub Profile
@armadsen
armadsen / BuildLibFLAC.sh
Created February 15, 2013 19:52
Quickly thrown together script to build libFLAC as a 64/32-bit universal binary on Mac OS X 10.8.
#!/usr/bin/env bash
# Put this script in the libFLAC source directory, and make sure it's executable (chmod +x BuildLibFlac.sh), then run it (./BuildLibFLAC.sh)
# Note that this was written to be used on 10.8 with Xcode 4.6 and FLAC 1.2.1. It may/will need to be changed for future versions of the OS, tools, and/or FLAC
env CFLAGS="-arch x86_64" CPPFLAGS="-arch x86_64" LDFLAGS="-arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.5" ./configure --disable-asm-optimizations --enable-static --disable-shared --disable-ogg
make clean; make
cp src/libFLAC/.libs/libFLAC.a ./libFLAC64.a
make clean;
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
{
id varA;
}
@property (nonatomic, strong) id varA;
@end
@armadsen
armadsen / MethodInProtocolsRequiredExample.m
Last active December 10, 2015 04:28
Complete example/test program for quick and dirty function to determine if a method in an Objective-C protocol is required or optional. Example for my answer to this stackoverflow question: http://stackoverflow.com/questions/14043930/how-to-identify-a-protocol-method-is-optional-during-runtime/14044086#14044086
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@protocol TestProtocol <NSObject>
@required
- (void)methodA;
@optional
- (void)methodB;
@end
@armadsen
armadsen / FunctionPointerFromMethod.m
Created May 19, 2012 18:50
Simple example of getting a function pointer to an Objective-C method and calling it
// To compile and test this from the command line:
//
// $> clang FunctionPointerFromMethod.m -ObjC -framework Foundation -fobjc-arc
// $> ./a.out
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
- (void)someMethodThatTakesOneStringArgument:(NSString *)string;
@end