A colossal Dreamer: GR鐵塔-天生我材

ObjC Action Delegation(Handling) Cases 본문

Development/아이폰

ObjC Action Delegation(Handling) Cases

江多林 2018. 3. 29. 11:26

Old style

@protocol XXXDelegate

// YES => 본체의 내부 로직 실행

// NO => delegator 쪽에서 처리하거나, 버리기

- (BOOL)shouldAction....

@end


Mid age style

ref: UIAlertController, UIAlertAction


Cur style

typedef NS_ENUM(NSInteger, Policy) {

Cancel,

Allow

}


@protocol

// Action을 살펴보고,

// decisionHander 를 호출하는 방식.

//     본체에서 처리하려면, Allow

//     delegator에서 처리하거나 버리려면, Cancel

- (void)decidePolicyForAction:(Action *)action decisionHandler:(void (^)(Policy))decisionHandler

@end