我调用addImageToQueue后,我的应用程序崩溃了.我添加了initWithObjects:forKeys:count:但它没有帮助我.
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSDictionary initWithObjects:forKeys:count:]:
method only defined for abstract class.
Define -[DictionaryWithTag initWithObjects:forKeys:count:]!'
Run Code Online (Sandbox Code Playgroud)
我的代码
- (void)addImageToQueue:(NSDictionary *)dict
{
DictionaryWithTag *dictTag = [DictionaryWithTag dictionaryWithDictionary:dict];
}
@interface DictionaryWithTag : NSDictionary
@property (nonatomic, assign) int tag;
- (id)initWithObjects:(id *)objects forKeys:(id *)keys count:(NSUInteger)count;
@end
@implementation DictionaryWithTag
@synthesize tag;
- (id)initWithObjects:(id *)objects forKeys:(id *)keys count:(NSUInteger)count
{
return [super initWithObjects:objects forKeys:keys count:count];
}
@end
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何从NSDictionary继承?
根据API,我必须覆盖方法:
setObject:forKey:
removeObjectForKey:
initWithObjects:forKeys:
count
objectForKey:
keyEnumerator
Run Code Online (Sandbox Code Playgroud)
你能提供一个关于如何覆盖它们的例子吗?