mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-01 22:42:51 +08:00
Conflicts: Code/CoreData/RKManagedObjectLoader.h Code/CoreData/RKManagedObjectLoader.m Code/CoreData/RKManagedObjectMapping.m Code/CoreData/RKManagedObjectMappingOperation.m Code/CoreData/RKManagedObjectStore.m Code/CoreData/RKManagedObjectThreadSafeInvocation.h Code/CoreData/RKManagedObjectThreadSafeInvocation.m Code/CoreData/RKSearchableManagedObject.m Code/ObjectMapping/RKObjectLoader.m Code/ObjectMapping/RKObjectMapper.h Code/ObjectMapping/RKObjectMappingOperation.m RestKit.xcodeproj/project.pbxproj Tests/Logic/CoreData/RKManagedObjectThreadSafeInvocationTest.m
85 lines
3.4 KiB
Objective-C
85 lines
3.4 KiB
Objective-C
//
|
|
// RKConnectionMapping.m
|
|
// RestKit
|
|
//
|
|
// Created by Charlie Savage on 5/15/12.
|
|
// Copyright (c) 2009-2012 RestKit. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
#import "RKConnectionMapping.h"
|
|
#import "NSManagedObject+ActiveRecord.h"
|
|
#import "RKEntityMapping.h"
|
|
#import "RKObjectManager.h"
|
|
#import "RKManagedObjectCaching.h"
|
|
#import "RKDynamicObjectMappingMatcher.h"
|
|
|
|
@interface RKConnectionMapping()
|
|
@property (nonatomic, retain) NSString *relationshipName;
|
|
@property (nonatomic, retain) NSString *destinationKeyPath;
|
|
@property (nonatomic, retain) RKObjectMappingDefinition *mapping;
|
|
@property (nonatomic, retain) RKDynamicObjectMappingMatcher *matcher;
|
|
@property (nonatomic, retain) NSString *sourceKeyPath;
|
|
@end
|
|
|
|
@implementation RKConnectionMapping
|
|
|
|
@synthesize relationshipName = _relationshipName;
|
|
@synthesize destinationKeyPath = _destinationKeyPath;
|
|
@synthesize mapping = _mapping;
|
|
@synthesize matcher = _matcher;
|
|
@synthesize sourceKeyPath = _sourceKeyPath;
|
|
|
|
+ (RKConnectionMapping *)connectionMappingForRelationship:(NSString *)relationshipName fromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping
|
|
{
|
|
RKConnectionMapping *mapping = [[self alloc] initWithRelationshipName:relationshipName sourceKeyPath:sourceKeyPath destinationKeyPath:destinationKeyPath mapping:objectOrDynamicMapping matcher:nil];
|
|
return [mapping autorelease];
|
|
}
|
|
|
|
+ (RKConnectionMapping*)connectionMappingForRelationship:(NSString *)relationshipName fromKeyPath:(NSString *)sourceKeyPath toKeyPath:(NSString *)destinationKeyPath withMapping:(RKObjectMappingDefinition *)objectOrDynamicMapping matcher:(RKDynamicObjectMappingMatcher *)matcher
|
|
{
|
|
RKConnectionMapping *mapping = [[self alloc] initWithRelationshipName:relationshipName sourceKeyPath:sourceKeyPath destinationKeyPath:destinationKeyPath mapping:objectOrDynamicMapping matcher:matcher];
|
|
return [mapping autorelease];
|
|
}
|
|
|
|
- (id)initWithRelationshipName:(NSString *)relationshipName sourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath mapping:(RKObjectMappingDefinition *)objectOrDynamicMapping matcher:(RKDynamicObjectMappingMatcher *)matcher
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
self.relationshipName = relationshipName;
|
|
self.sourceKeyPath = sourceKeyPath;
|
|
self.destinationKeyPath = destinationKeyPath;
|
|
self.mapping = objectOrDynamicMapping;
|
|
self.matcher = matcher;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id)copyWithZone:(NSZone *)zone
|
|
{
|
|
return [[[self class] allocWithZone:zone] initWithRelationshipName:self.relationshipName sourceKeyPath:self.sourceKeyPath destinationKeyPath:self.destinationKeyPath mapping:self.mapping matcher:self.matcher];
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
self.relationshipName = nil;
|
|
self.destinationKeyPath = nil;
|
|
self.mapping = nil;
|
|
self.matcher = nil;
|
|
self.sourceKeyPath = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
@end
|