Making Xcode complain about a missing parameter-Collection of common programming errors

First, I strongly recommend defining types to represent your blocks – makes them a lot easier to work with, especially if you need to refactor the parameters.

You can’t write code that distinguishes between “I set this property to nil” or “the runtime initialized this property to nil”, at least not without some crazy runtime code to check the stack. Only option I can think of would be to use the null object pattern. Before I elaborate, bear in mind that I haven’t actually tried to test this, but it should work. Define a block that means ‘has no value’ and set your property to point to that block on init. Then you can compare to that NullBlock at runtime to identify if someone explicitly set the property to nil (because it would be nil at that point) or gave it a real non-nil value.

Alternatively, if you don’t mind manually writing your set accessors, you could have a BOOL that tracks if someone set the property explicitly. Then when you call the block just check if someone actually set the value or not.

@synthesize onTouchBlock=_onTouchBlock;
MyBlock _onTouchBlock;
BOOL _onTouchBlockWasSet;

- (void)setOnTouchBlock:(MyBlock)block {
 _onTouchBlockWasSet = YES;
 _onTouchBlock = block;
}

I would not recommend passing the value in the initializer because that makes it tied to the creation of that object type. If you wanted to change the block in code based on some condition, you’d be back to square one. Also, it prevents you from using storyboards which create that object.