CocoaDev

Edit AllPages

slerp has a whole mess of handy snippets: http://phonedev.tumblr.com


Take a screen shot

Thanks to Erica Sadun, I believe.

@implementation UIView (Snapshot)

@end


Subclassing UIKit

To see what the rest of UIKit is expecting from your subclass, you can log calls to respondsToSelector: and the like.


If you use a function that returns a float or a double, you’ll get a linker error on the function objc_msgSend_fpret. Here’s a standin until the toolchain is fixed:

double objc_msgSend_fpret(id self, SEL op, …) { Method method = class_getInstanceMethod(self->isa, op); int numArgs = method_getNumberOfArguments(method);

if(numArgs == 2) {
	double (*imp)(id, SEL);
	imp = (double (*)(id, SEL))method->method_imp;
	return imp(self, op);
} else if(numArgs == 3) {
	// FIXME: this code assumes the 3rd arg is 4 bytes
	va_list ap;
	va_start(ap, op);
	double (*imp)(id, SEL, void *);
	imp = (double (*)(id, SEL, void *))method->method_imp;
	return imp(self, op, va_arg(ap, void *));
}

// FIXME: need to work with multiple arguments/types
fprintf(stderr, "ERROR: objc_msgSend_fpret, called on <%s %p> with selector %s, had to return 0.0\n", object_getClassName(self), self, sel_getName(op));
return 0.0;	 }

Update: http://www.tuaw.com/2007/09/04/iphone-coding-using-the-slider/ says that this is no longer necessary as of the v.20 toolchain.