mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-29 05:05:34 +08:00
Added error logging and notifications for persistent data store failures.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
#import "RKModelMapper.h"
|
||||
#import "JSON.h"
|
||||
|
||||
@interface RKMappingFormatJSONParser : NSObject <RKMappingFormatParser> {
|
||||
|
||||
SBJSON* _parser;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
#import <CoreData/CoreData.h>
|
||||
|
||||
/**
|
||||
* Notifications
|
||||
*/
|
||||
extern NSString* const RKManagedObjectStoreDidFailSaveNotification;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@interface RKManagedObjectStore : NSObject {
|
||||
NSString* _storeFilename;
|
||||
NSManagedObjectModel* _managedObjectModel;
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
NSArray* _dateFormats;
|
||||
NSTimeZone* _remoteTimeZone;
|
||||
NSTimeZone* _localTimeZone;
|
||||
SEL _comparisonProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user