[30755] users/rhwood/MacPorts.Framework
source_changes at macosforge.org
source_changes at macosforge.org
Tue Nov 6 02:11:24 PST 2007
Revision: 30755
http://trac.macosforge.org/projects/macports/changeset/30755
Author: rhwood at macports.org
Date: 2007-11-06 02:11:24 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
Add a class that handles most of the methods that need to be implemented to subclass NSMutableDictionary
Added Paths:
-----------
users/rhwood/MacPorts.Framework/MPMutableDictionary.h
users/rhwood/MacPorts.Framework/MPMutableDictionary.m
Added: users/rhwood/MacPorts.Framework/MPMutableDictionary.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPMutableDictionary.h (rev 0)
+++ users/rhwood/MacPorts.Framework/MPMutableDictionary.h 2007-11-06 10:11:24 UTC (rev 30755)
@@ -0,0 +1,32 @@
+//
+// MPMutableDictionary.h
+// MacPorts.Framework
+//
+// Created by Randall Hansen Wood on 26/9/2007.
+// Copyright 2007 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+ at interface MPMutableDictionary : NSMutableDictionary {
+
+ NSMutableDictionary *embeddedDictionary;
+
+}
+
+- (id)init;
+- (id)initWithCapacity:(unsigned)numItems;
+
+- (unsigned)count;
+- (NSEnumerator *)keyEnumerator;
+- (id)objectForKey:(id)aKey;
+- (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setDictionary:(NSDictionary *)otherDictionary;
+- (NSString *)description;
+
++ (Class)classForKeyedUnarchiver;
+- (Class)classForKeyedArchiver;
+
+ at end
Added: users/rhwood/MacPorts.Framework/MPMutableDictionary.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPMutableDictionary.m (rev 0)
+++ users/rhwood/MacPorts.Framework/MPMutableDictionary.m 2007-11-06 10:11:24 UTC (rev 30755)
@@ -0,0 +1,76 @@
+//
+// MPMutableDictionary.m
+// MacPorts.Framework
+//
+// Created by Randall Hansen Wood on 26/9/2007.
+// Copyright 2007 __MyCompanyName__. All rights reserved.
+//
+
+#import "MPMutableDictionary.h"
+
+
+ at implementation MPMutableDictionary
+
+- (id)init {
+ self = [super init];
+ if (self != nil) {
+ embeddedDictionary = [[NSMutableDictionary alloc] initWithCapacity:0];
+ }
+ return self;
+}
+
+- (id)initWithCapacity:(unsigned)numItems {
+ self = [super init];
+ if (self != nil) {
+ embeddedDictionary = [[NSMutableDictionary alloc] initWithCapacity:numItems];
+ }
+ return self;
+}
+
+- (void) dealloc {
+ [embeddedDictionary release];
+ [super dealloc];
+}
+
+- (unsigned)count {
+ return [embeddedDictionary count];
+}
+
+- (NSEnumerator *)keyEnumerator {
+ return [embeddedDictionary keyEnumerator];
+}
+
+- (id)objectForKey:(id)aKey {
+ if ([aKey isEqualToString:@"compositeVersion"]) {
+ return [[[embeddedDictionary objectForKey:@"version"] stringByAppendingString:@"_"] stringByAppendingString:[embeddedDictionary objectForKey:@"revision"]];
+ }
+ return [embeddedDictionary objectForKey:aKey];
+}
+
+- (void)removeObjectForKey:(id)aKey {
+ [embeddedDictionary removeObjectForKey:aKey];
+}
+
+- (void)setObject:(id)anObject forKey:(id)aKey {
+ [self willChangeValueForKey:aKey];
+ [embeddedDictionary setObject:anObject forKey:aKey];
+ [self didChangeValueForKey:aKey];
+}
+
+- (void)setDictionary:(NSDictionary *)otherDictionary {
+ [embeddedDictionary setDictionary:otherDictionary];
+}
+
+- (NSString *)description {
+ return [embeddedDictionary description];
+}
+
+- (Class)classForKeyedArchiver {
+ return [MPMutableDictionary class];
+}
+
++ (Class)classForKeyedUnarchiver {
+ return [MPMutableDictionary class];
+}
+
+ at end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071106/1f65e974/attachment.html
More information about the macports-changes
mailing list