• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
exception in class derived from NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: exception in class derived from NSMutableDictionary
      • From: Prachi Gauriar <email@hidden>
    • Re: exception in class derived from NSMutableDictionary
      • From: Greg Titus <email@hidden>
    • Re: exception in class derived from NSMutableDictionary
      • From: Dylan Adams <email@hidden>
  • Prev by Date: Re: A couple of NSTable questions
  • Next by Date: NSArray problem for a newbie
  • Previous by thread: Re: A couple of NSTable questions
  • Next by thread: Re: exception in class derived from NSMutableDictionary
  • Index(es):
    • Date
    • Thread