Skip to content

Instantly share code, notes, and snippets.

View PsychoH13's full-sized avatar

Remy Demarest PsychoH13

  • Grasse, France / San Francisco, California
View GitHub Profile
#import <Foundation/Foundation.h>
@implementation NSArray (BlocksTest)
- (void) do:(void (^)(id))aBlock;
{
[self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
aBlock(obj);
}];
@interface Class0 @end
@interface Class1 @end
@interface Class2 {}
+ (id)test:(Class0 *)class;
- (id)test:(Class0 *)class;
@end
@interface Class3 {}
+ (id)test:(Class1 *)class;
@PsychoH13
PsychoH13 / ObjC-Blocks-Fun.m
Created November 20, 2009 08:54
SmallTalkish ObjC blocks in Foundation
#import <Foundation/Foundation.h>
#import "PSYSmallTalkBlocks.h"
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int value = 0;
[PSYNumObj(value == 10) ifTrue:PSYIdVoidBlk({
@PsychoH13
PsychoH13 / PSYBlockTimer.h
Created December 7, 2009 06:19
Fire an NSTimer using a block as execution code.
/*
Copyright (c) 2009 Remy Demarest
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
/*
Copyright (c) 2008, Remy Demarest
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
NSPoint PSYPointInBezierPath(NSPoint *points, NSInteger pointCount, CGFloat t,
NSPoint *getPoints, NSInteger getPointCount)
{
if(getPointCount > 0 && pointCount == getPointCount)
for(int i = 0; i < getPointCount; i++)
getPoints[i] = points[i];
if(pointCount <= 1) return *points;
NSPoint *newPoints = calloc(pointCount - 1, sizeof(NSPoint));
@PsychoH13
PsychoH13 / NSMutableData+PSYDataWriter.h
Created August 3, 2010 23:00
A class enabling NSData object scanning and a category enabling NSMutableData writing.
/*
NSMutableData+PSYDataWriter.h
Created by Remy "Psy" Demarest on 22/01/2012.
Copyright (c) 2012. Remy "Psy" Demarest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@PsychoH13
PsychoH13 / PSYLayerConstraintLayoutManager.h
Created November 28, 2010 00:25
Layout manager using direct layer references
/*
* PSYLayerConstraintLayoutManager.h
* LayoutManager
*
* Created by Remy Demarest on 27/02/2010.
* Copyright (c) 2010, Remy Demarest
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#import <UIKit/UIKit.h>
@interface UIControl (PSYBlockTargetAddition)
- (id)addTargetForControlEvents:(UIControlEvents)controlEvents usingBlock:(void(^)(id sender, UIEvent *event))block;
- (void)removeTarget:(id)target forControlEvents:(UIControlEvents)controlEvents;
@end
@PsychoH13
PsychoH13 / New JSONKit.m
Created May 20, 2011 18:29
Difference of building JSON...
isClass = [object PSYJK_JSONClass];
if(isClass == PSYJKClassUnknown