/ Published in: Objective C

This method will alloc the current class unless the device is a phone (also defined here). Then it will try to alloc the class with the suffix "Phone."
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#define IS_PHONE UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone #define ALLOC_PER_DEVICE() id retVal = nil; \ if (IS_PHONE && ![className hasSuffix:@"Phone"]) {\ Class newClass = NSClassFromString(className);\ retVal = [newClass alloc];\ }\ if (!retVal)\ retVal = [super alloc];\ return retVal\ // Sample Usage + (id) alloc { ALLOC_PER_DEVICE(); }
Comments
