exception in class derived from NSMutableDictionary
exception in class derived from NSMutableDictionary
- Subject: exception in class derived from NSMutableDictionary
- From: Robert G Palmer Jr <email@hidden>
- Date: Wed, 30 Jul 2003 12:03:19 -0400
I have a class that I have derived from NSMutableDictionary - solely
for the purpose of being able to add items using a custom method. If I
execute either of the first two pieces of code, they work fine. If I
execute the third, I get an exception on the count method with the
following message:
2003-07-30 11:47:27.964 V360Locator[1766] An uncaught exception was
raised
2003-07-30 11:47:27.965 V360Locator[1766] *** -count only defined for
abstract class. Define -[VideoSensorCollection count]!
2003-07-30 11:47:27.965 V360Locator[1766] *** Uncaught exception:
<NSInvalidArgumentException> *** -count only defined for abstract
class. Define -[VideoSensorCollection count]!
Any help in expanding my understanding of this would be greatly
appreciated. Also, now that I look at it, would it not make sense to
have my "VideoSensorCollection" simply be a Category on the
NSMutableDictionary class?
Code 1:
NSDictionary* aDict;
aDict = [[NSDictionary alloc] init];
int a = [aDict count];
Code 2:
NSMutableDictionary* aDict;
aDict = [[NSMutableDictionary alloc] init];
int a = [aDict count];
Code 3:
VideoSensorCollection* aDict;
aDict = [[VideoSensorCollection alloc] init];
int a = [aDict count];
Here is my class:
VideoSensorCollection.h:
@interface VideoSensorCollection : NSMutableDictionary
- (void) addSensorByMAC:(NSString *)hwAddr withIP:(NSString *)ipBuf
withDescription:(NSString *)desc;
- (void) updateSensorWithMAC:(NSString *)hwAddr byTag:(int)tagID
withTagInfo:(NSString *)tagInfo;
@end
VideoSensorCollection.m:
@implementation VideoSensorCollection
- (void) addSensorByMAC:(NSString *)hwAddr withIP:(NSString *)ipBuf
withDescription:(NSString *)desc
{
VideoSensor* sensor = [[VideoSensor alloc] init];
[sensor setMacAddress: hwAddr];
[sensor setIpAddress: ipBuf];
[sensor setProduct: desc];
[self setObject:sensor forKey:hwAddr];
return;
}
- (void) updateSensorWithMAC:(NSString *)hwAddr byTag:(int)tagID
withTagInfo:(NSString *)tagInfo
{
VideoSensor* sensor = [self objectForKey:hwAddr];
// do something with the sensor object
}
@end
Thanks,
Robert Palmer, Jr
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.