mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-29 05:05:34 +08:00
Created DBTopic model and mapped attributes
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DBTopic.h
|
||||
// DiscussionBoard
|
||||
//
|
||||
// Created by Daniel Hammond on 1/7/11.
|
||||
// Copyright 2011 Two Toasters. All rights reserved.
|
||||
//
|
||||
|
||||
#import <RestKit/RestKit.h>
|
||||
#import <RestKit/CoreData/CoreData.h>
|
||||
|
||||
@interface DBTopic : RKManagedObject {
|
||||
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSNumber* topicID;
|
||||
@property (nonatomic, retain) NSString* name;
|
||||
@property (nonatomic, retain) NSNumber* userID;
|
||||
@property (nonatomic, retain) NSDate* createdAt;
|
||||
@property (nonatomic, retain) NSDate* updatedAt;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// DBTopic.m
|
||||
// DiscussionBoard
|
||||
//
|
||||
// Created by Daniel Hammond on 1/7/11.
|
||||
// Copyright 2011 Two Toasters. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DBTopic.h"
|
||||
|
||||
@implementation DBTopic
|
||||
|
||||
@dynamic topicID;
|
||||
@dynamic name;
|
||||
@dynamic userID;
|
||||
@dynamic createdAt;
|
||||
@dynamic updatedAt;
|
||||
|
||||
#pragma mark RKObjectMappable methods
|
||||
|
||||
+ (NSDictionary*)elementToPropertyMappings {
|
||||
return [NSDictionary dictionaryWithKeysAndObjects:
|
||||
@"id",@"topicID",
|
||||
@"name",@"name",
|
||||
@"user_id",@"userID",
|
||||
@"created_at",@"createdAt",
|
||||
@"updated_at",@"updatedAt",
|
||||
nil];
|
||||
}
|
||||
|
||||
+ (NSString*)primaryKeyProperty {
|
||||
return @"topicID";
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -7,6 +7,9 @@
|
||||
//
|
||||
|
||||
#import "DiscussionBoardAppDelegate.h"
|
||||
#import <RestKit/RestKit.h>
|
||||
|
||||
#import "DBTopic.h"
|
||||
|
||||
@implementation DiscussionBoardAppDelegate
|
||||
|
||||
@@ -17,12 +20,12 @@
|
||||
#pragma mark Application lifecycle
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
return YES;
|
||||
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:kDBBaseURLString];
|
||||
RKObjectMapper* mapper = objectManager.mapper;
|
||||
[mapper registerClass:[DBTopic class] forElementNamed:@"topic"];
|
||||
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user