forked from 343max/NSObject-Expectation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSObject+Expectation.h
75 lines (59 loc) · 1.73 KB
/
NSObject+Expectation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// NSObject+SafeObject.h
//
// Created by Max Winde on 15.05.13.
// Copyright (c) 2013 Max Winde. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSObject (Expectation)
/**
Returns self if it is kind of class aClass or nil otherwise
@return self or nil
*/
- (id)nilUnlessKindOfClass:(Class)aClass;
/**
Returns self if it responds to the given selector or nil otherwise
@return self or nil
*/
- (id)nilUnlessRespondsToSelector:(SEL)selector;
/**
Returns self if it conforms to the given protocol or nil otherwise
@return self or nil
*/
- (id)nilUnlessConformsToProtocol:(Protocol *)aProtocol;
#pragma mark - Default Value
/**
Returns object if it is kind of class aClass or self otherwise
@return object or self
*/
- (id)unless:(NSObject *)object isKindOfClass:(Class)aClass;
/**
Returns object if it responds to the given selector or nil otherwise
@return object or self
*/
- (id)unless:(NSObject *)object respondsToSelector:(SEL)selector;
/**
Returns objecy if it conforms to the given protocol or nil otherwise
@return object or self
*/
- (id)unless:(NSObject *)object conformsToProtocol:(Protocol *)aProtocol;
#pragma mark - Deprectated
/**
Returns self if it is kind of class aClass or nil otherwise
@deprecated use nilUnlessKindOfClass: instead
@return self or nil
*/
- (id)ifIsKindOfClass:(Class)aClass;
/**
Returns self if it responds to the given selector or nil otherwise
@deprecated use nilUnlessRespondsToSelector: instead
@return self or nil
*/
- (id)IfRespondsToSelector:(SEL)selector;
/**
Returns self if it conforms to the given protocol or nil otherwise
@deprecated use nilUnlessConformsToProtocol: instead
@return self or nil
*/
- (id)IfConformsToProtocol:(Protocol *)aProtocol;
@end