Skip to content

Instantly share code, notes, and snippets.

@aufflick aufflick/Fraction.h
Created May 29, 2013

What would you like to do?
#include <stdio.h>
int main() {
void (^hello)(void) = ^(void) {
printf("Hello, block!\n");
return 0;
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
#import "Fraction.h"
#import <stdio.h>
@implementation Fraction
-(void) print {
printf( "%i/%i", numerator, denominator );
-(void) setNumerator: (int) n {
numerator = n;
-(void) setDenominator: (int) d {
denominator = d;
-(int) denominator {
return denominator;
-(int) numerator {
return numerator;
#include <dispatch/dispatch.h>
#import <stdio.h>
#import "Fraction.h"
int main( int argc, const char *argv[] ) {
dispatch_queue_t queue = dispatch_queue_create(NULL, NULL);
Fraction *frac = [[Fraction alloc] init];
[frac setNumerator: 1];
[frac setDenominator: 3];
// print it
dispatch_sync(queue, ^{
printf( "The fraction is: " );
[frac print];
printf( "\n" );
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.