mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-22 11:46:05 +08:00
Use instancetype in constructors for increased subclassing friendliness
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
@param value The value that is expected to be set for the relationship when the connection is established.
|
||||
@return A newly constructed connection expectation, initialized with the given relationship name, attributes dictionary, and expected value.
|
||||
*/
|
||||
+ (id)expectationWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value;
|
||||
+ (instancetype)expectationWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value;
|
||||
|
||||
/**
|
||||
Initializes the receiver with the given relationship name, attributes dictionary, and value.
|
||||
@@ -50,7 +50,7 @@
|
||||
@param value The value that is expected to be set for the relationship when the connection is established.
|
||||
@return The receiver, initialized with the given relationship name, attributes dictionary, and expected value.
|
||||
*/
|
||||
- (id)initWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value;
|
||||
- (instancetype)initWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value;
|
||||
|
||||
///------------------------------------
|
||||
/// @name Accessing Expectation Details
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
@implementation RKConnectionTestExpectation
|
||||
|
||||
+ (id)expectationWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
+ (instancetype)expectationWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
{
|
||||
return [[self alloc] initWithRelationshipName:relationshipName attributes:attributes value:value];
|
||||
}
|
||||
|
||||
- (id)initWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
- (instancetype)initWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
{
|
||||
NSParameterAssert(relationshipName);
|
||||
NSAssert(value == nil ||
|
||||
|
||||
@@ -95,7 +95,7 @@ extern NSString * const RKMappingTestExpectationErrorKey;
|
||||
@param destinationObject The destionation object being to.
|
||||
@return A new mapping test object for a mapping, a source object and a destination object.
|
||||
*/
|
||||
+ (RKMappingTest *)testForMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject;
|
||||
+ (instancetype)testForMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject;
|
||||
|
||||
/**
|
||||
Initializes the receiver with a given object mapping, source object, and destination object.
|
||||
@@ -105,7 +105,7 @@ extern NSString * const RKMappingTestExpectationErrorKey;
|
||||
@param destinationObject The destionation object being to.
|
||||
@return The receiver, initialized with mapping, sourceObject and destinationObject.
|
||||
*/
|
||||
- (id)initWithMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject;
|
||||
- (instancetype)initWithMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject;
|
||||
|
||||
///----------------------------
|
||||
/// @name Managing Expectations
|
||||
|
||||
@@ -130,7 +130,7 @@ NSString * const RKMappingTestVerificationFailureException = @"RKMappingTestVeri
|
||||
|
||||
@implementation RKMappingTest
|
||||
|
||||
+ (RKMappingTest *)testForMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject
|
||||
+ (instancetype)testForMapping:(RKMapping *)mapping sourceObject:(id)sourceObject destinationObject:(id)destinationObject
|
||||
{
|
||||
return [[self alloc] initWithMapping:mapping sourceObject:sourceObject destinationObject:destinationObject];
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ typedef BOOL (^RKMappingTestExpectationEvaluationBlock)(RKPropertyMappingTestExp
|
||||
@param destinationKeyPath A key path on the destination object that should be mapped onto.
|
||||
@return An expectation specifying that sourceKeyPath should be mapped to destinationKeyPath.
|
||||
*/
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath;
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath;
|
||||
|
||||
/**
|
||||
Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destination object with a given value.
|
||||
@@ -58,7 +58,7 @@ typedef BOOL (^RKMappingTestExpectationEvaluationBlock)(RKPropertyMappingTestExp
|
||||
@param value The value that is expected to be assigned to the destination object at destinationKeyPath.
|
||||
@return An expectation specifying that sourceKeyPath should be mapped to destinationKeyPath with value.
|
||||
*/
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath value:(id)value;
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath value:(id)value;
|
||||
|
||||
/**
|
||||
Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destinaton object and that the attribute mapping and value should evaluate to true with a given block.
|
||||
@@ -68,7 +68,7 @@ typedef BOOL (^RKMappingTestExpectationEvaluationBlock)(RKPropertyMappingTestExp
|
||||
@param evaluationBlock A block with which to evaluate the success of the mapping.
|
||||
@return An expectation specifying that sourceKeyPath should be mapped to destinationKeyPath with value.
|
||||
*/
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath evaluationBlock:(RKMappingTestExpectationEvaluationBlock)evaluationBlock;
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath evaluationBlock:(RKMappingTestExpectationEvaluationBlock)evaluationBlock;
|
||||
|
||||
/**
|
||||
Creates and returns a new expectation specifying that a key path in a source object should be mapped to another key path on a destinaton object using a specific object mapping for the relationship.
|
||||
@@ -78,7 +78,7 @@ typedef BOOL (^RKMappingTestExpectationEvaluationBlock)(RKPropertyMappingTestExp
|
||||
@param mapping An object mapping that is expected to be used for mapping the nested relationship.
|
||||
@return An expectation specifying that sourceKeyPath should be mapped to destinationKeyPath using a specific object mapping.
|
||||
*/
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath mapping:(RKMapping *)mapping;
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath mapping:(RKMapping *)mapping;
|
||||
|
||||
///-------------------------
|
||||
/// @name Expectation Values
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
@implementation RKPropertyMappingTestExpectation
|
||||
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath
|
||||
{
|
||||
RKPropertyMappingTestExpectation *expectation = [self new];
|
||||
expectation.sourceKeyPath = sourceKeyPath;
|
||||
@@ -40,7 +40,7 @@
|
||||
return expectation;
|
||||
}
|
||||
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath value:(id)value
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath value:(id)value
|
||||
{
|
||||
RKPropertyMappingTestExpectation *expectation = [self new];
|
||||
expectation.sourceKeyPath = sourceKeyPath;
|
||||
@@ -50,7 +50,7 @@
|
||||
return expectation;
|
||||
}
|
||||
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath evaluationBlock:(RKMappingTestExpectationEvaluationBlock)evaluationBlock
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath evaluationBlock:(RKMappingTestExpectationEvaluationBlock)evaluationBlock
|
||||
{
|
||||
RKPropertyMappingTestExpectation *expectation = [self new];
|
||||
expectation.sourceKeyPath = sourceKeyPath;
|
||||
@@ -60,7 +60,7 @@
|
||||
return expectation;
|
||||
}
|
||||
|
||||
+ (RKPropertyMappingTestExpectation *)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath mapping:(RKMapping *)mapping
|
||||
+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath mapping:(RKMapping *)mapping
|
||||
{
|
||||
RKPropertyMappingTestExpectation *expectation = [self new];
|
||||
expectation.sourceKeyPath = sourceKeyPath;
|
||||
|
||||
Reference in New Issue
Block a user