From 381baa3eacb249b79a2657a705b06ff4ef19f110 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 6 Jun 2008 14:08:02 -0400 Subject: [PATCH] Adding NSDictionary archiving and unarchiving abilities to Breakpoint * Source/Breakpoint.m+h: (initWithDictionary:): New method (dictionary): New method --- Source/Breakpoint.h | 3 +++ Source/Breakpoint.m | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Source/Breakpoint.h b/Source/Breakpoint.h index 3422155..b8bfa27 100644 --- a/Source/Breakpoint.h +++ b/Source/Breakpoint.h @@ -29,5 +29,8 @@ @property(readwrite, assign) int debuggerId; - (id)initWithLine:(int)l inFile:(NSString *)f; +- (id)initWithDictionary:(NSDictionary *)dict; + +- (NSDictionary *)dictionary; @end diff --git a/Source/Breakpoint.m b/Source/Breakpoint.m index 26f5f8e..e91224d 100644 --- a/Source/Breakpoint.m +++ b/Source/Breakpoint.m @@ -34,6 +34,19 @@ return self; } +/** + * Creates a Breakpoint from the values of an NSDictionary + */ +- (id)initWithDictionary:(NSDictionary *)dict +{ + if (self = [super init]) + { + file = [dict valueForKey:@"file"]; + line = [[dict valueForKey:@"line"] intValue]; + } + return self; +} + /** * Determines if two breakpoints are equal */ @@ -50,6 +63,14 @@ return ([file hash] << 8) + line; } +/** + * Returns an NSDictionary of the data so it can be stored in NSUserDefaults + */ +- (NSDictionary *)dictionary +{ + return [NSDictionary dictionaryWithObjectsAndKeys:file, @"file", [NSNumber numberWithInt:line], @"line", nil]; +} + /** * Pretty-print */ -- 2.43.5