Skip to content

Instantly share code, notes, and snippets.

View gist:8819139
@interface ViewController : NSObject
<BMLazy>
@property (nonatomic, strong, bm_assign_once) NSString *stubObject;
@end
-(void)onSomeEvent
View BMXyz.h
@interface BMXyz
@property ( nonatomic, readwrite ) NSString* writeOnceStub;
@end
View BMXyz_2.h
@interface BMXyz
@property ( nonatomic, readwrite, bm_final ) NSString* writeOnceStub;
@end
@dodikk
dodikk / UITableViewDelegate-defaults.m
Created Feb 13, 2014
Return values to get default behaviour for UITableViewDelegate methods
View UITableViewDelegate-defaults.m
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return -1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return -1;
}
View HookBySwizzling.mm
-(void)testLevelIsStoredAfterSuccessfullFetch
{
__block SCLevelResponse* receivedResponse = nil;
__block NSError* receivedError = nil;
SCItemsFileManagerCallbacks* callbacks = [ SCItemsFileManagerCallbacks new ];
{
callbacks.onLevelLoadedBlock = ^void( SCLevelResponse* response, NSError* error )
{
receivedResponse = response;
View AlternateWrapper.mm
-(void)onLevelReloaded:( SCLevelResponse* )levelResponse
{
NSParameterAssert( nil != levelResponse );
NSParameterAssert( nil != levelResponse.levelParentItem );
self->_loadedLevel = levelResponse;
// register cells as content has been loaded
for ( SCItem* item in levelResponse.levelContentItems )
{
View CustomCell.h
@interface MyCell : UITableViewCell
+(NSString*)reuseId;
@property ( nonatomic, strong ) MyCellController* cellController;
@end
@dodikk
dodikk / UIKit pch error
Created Mar 17, 2014
Werid clang errors
View UIKit pch error
fatal error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableView.h' has been modified since the precompiled header '/var/folders/fw/yrmk7vp92d531rckrfh6gqk40000gn/C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/5.0.2-5A3005/Xcode/ModuleCache/9OZFK1C8N0DD/UIKit.pcm' was built
View FactoryBlock.h
@protocol MyBlockProtocol;
typedef id<MyBlockProtocol>(^MyFactoryMethodBlock)( NSString* )objectId
View ClassClusterInternals.m
@implementation NSArray
-(instancetype)initWithXXX:()
{
NSArray_XXX_Impl* impl = [ NSArray_XXX_Impl new ];
// initialize impl