Permalink
Browse files

Implemented default debugging options in separate file and added the …

…file to prefixed header.
  • Loading branch information...
1 parent fd7b2c8 commit cf189381c2fb45b59f899832c1e0ae54b926375b @tomaz committed Apr 16, 2010
View
23 ...lication/Core Data Application with Unit Testing/Common/NSDictionary+GBDebuggingOptions.h
@@ -0,0 +1,23 @@
+//
+// NSDictionary+GBDebuggingOptions.h
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright (C) ___YEAR___, ___ORGANIZATIONNAME___. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface NSDictionary (GBDebuggingOptions)
+
+- (BOOL) canAddObjectsToDatabase;
+- (BOOL) canRemoveObjectsFromDatabase;
+
+@end
+
+@interface NSMutableDictionary (GBDebuggingOptions)
+
+- (void) setCanAddObjectsToDatabase:(BOOL)value;
+- (void) setCanRemoveObjectsFromDatabase:(BOOL)value;
+
+@end
View
49 ...lication/Core Data Application with Unit Testing/Common/NSDictionary+GBDebuggingOptions.m
@@ -0,0 +1,49 @@
+//
+// NSDictionary+GBDebuggingOptions.m
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright (C) ___YEAR___, ___ORGANIZATIONNAME___. All rights reserved.
+//
+
+#import "NSDictionary+GBDebuggingOptions.h"
+
+@implementation NSDictionary (DebuggingOptions)
+
+- (BOOL) isEnabled:(NSString*)key
+{
+ return ![[self objectForKey:key] boolValue];
+}
+
+- (BOOL) canAddObjectsToDatabase
+{
+ return [self isEnabled:@"PreventAddingObjectsToDatabase"];
+}
+
+- (BOOL) canRemoveObjectsFromDatabase
+{
+ return [self isEnabled:@"PreventRemovingObjectsFromDatabase"];
+}
+
+@end
+
+#pragma mark -
+
+@implementation NSMutableDictionary (DebuggingOptions)
+
+- (void) setEnabled:(BOOL)value forKey:(NSString*)key
+{
+ [self setObject:[NSNumber numberWithBool:!value] forKey:key];
+}
+
+- (void) setCanAddObjectsToDatabase:(BOOL)value
+{
+ [self setEnabled:value forKey:@"PreventAddingObjectsToDatabase"];
+}
+
+- (void) setCanRemoveObjectsFromDatabase:(BOOL)value
+{
+ [self setEnabled:value forKey:@"PreventRemovingObjectsFromDatabase"];
+}
+
+@end
View
1 ...lication/Core Data Application with Unit Testing/___PROJECTNAMEASIDENTIFIER____Prefix.pch
@@ -7,4 +7,5 @@
#import <BHLogger/BHLogger.h>
#import "NSObject+GBObject.h"
#import "NSDate+GBDate.h"
+ #import "NSDictionary+GBDebuggingOptions.h"
#endif

0 comments on commit cf18938

Please sign in to comment.