Added error logging and notifications for persistent data store failures.

This commit is contained in:
Blake Watters
2010-03-17 11:40:15 -04:00
parent f399f6c1ea
commit 6864a65303
5 changed files with 36 additions and 4 deletions

View File

@@ -7,6 +7,9 @@
//
#import "RKManagedObjectStore.h"
#import <UIKit/UIKit.h>
NSString* const RKManagedObjectStoreDidFailSaveNotification = @"RKManagedObjectStoreDidFailSaveNotification";
@interface RKManagedObjectStore (Private)
- (void)createPersistentStoreCoordinator;
@@ -61,6 +64,10 @@
[alert release];
}
@finally {
if (error) {
NSDictionary* userInfo = [NSDictionary dictionaryWithObject:error forKey:@"error"];
[[NSNotificationCenter defaultCenter] postNotificationName:RKManagedObjectStoreDidFailSaveNotification object:self userInfo:userInfo];
}
return error;
}
}

View File

@@ -7,9 +7,10 @@
//
#import "RKModelMapper.h"
#import "JSON.h"
@interface RKMappingFormatJSONParser : NSObject <RKMappingFormatParser> {
SBJSON* _parser;
}
@end

View File

@@ -7,12 +7,30 @@
//
#import "RKMappingFormatJSONParser.h"
#import "JSON.h"
@implementation RKMappingFormatJSONParser
- (id)init {
if (self = [super init]) {
_parser = [[SBJSON alloc] init];
}
return self;
}
- (void)dealloc {
[_parser release];
[super dealloc];
}
- (NSDictionary*)objectFromString:(NSString*)string {
return [[[[SBJSON alloc] init] autorelease] objectWithString:string];
id result = [_parser objectWithString:string];
if (nil == result) {
// TODO: Need to surface these errors in a better fashion
NSLog(@"[RestKit] RKMappingFormatJSONParser: Parser failed with error trace: %@", _parser.errorTrace);
}
return result;
}
@end

View File

@@ -8,6 +8,13 @@
#import <CoreData/CoreData.h>
/**
* Notifications
*/
extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
///////////////////////////////////////////////////////////////////
@interface RKManagedObjectStore : NSObject {
NSString* _storeFilename;
NSManagedObjectModel* _managedObjectModel;

View File

@@ -34,7 +34,6 @@
NSArray* _dateFormats;
NSTimeZone* _remoteTimeZone;
NSTimeZone* _localTimeZone;
SEL _comparisonProperty;
}
/**