Created DBTopic model and mapped attributes

This commit is contained in:
daniel
2011-01-07 13:17:13 -05:00
parent 4518543858
commit f4f6b862cd
3 changed files with 67 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}