我明白了
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM metadata]: unrecognized selector sent to instance 0xd0b6250'
当我到达并执行这部分代码时:
IDTherapyMetadata* meta = [self.dataCon getMetaDataFromId:content.metadata];
dataCon 中的方法如下所示:
-(IDTherapyMetadata*)getMetaDataFromId:(NSString*)metaDataId
{
for (IDTherapyMetadata* metadata in self.parser.metadata)
{
if([metaDataId compare:metadata.objId] == NSOrderedSame)
{
return metadata;
}
}
return nil;
}
奇怪的是,如果我写
IDTherapyMetadata* meta = [self.dataCon getMetaDataFromId:[content valueForKey:@"metadata"]];
相反,它工作得很好。
但是我希望能够使用点符号并查看苹果的文档 https://developer.apple.com/library/ios/documentation/cocoa/conceptual/KeyValueCoding/Articles/BasicPrinciples.html 并没有帮助我。
为什么我会出现这种行为,我该如何解决?
任何帮助是极大的赞赏
编辑: IDTherapyContents.h 的代码:
#import <Foundation/Foundation.h>
@interface IDTherapyContents : NSObject
@property (nonatomic, copy)NSString* urlId;
@property (nonatomic, copy)NSString* url;
@property (nonatomic, copy)NSString* type;
@property (nonatomic, copy)NSString* timestamp;
@property (nonatomic, copy)NSString* metadata;
@property (nonatomic, copy)NSString* lang;
@property (nonatomic, copy)NSString* objId;
//methods
-(id)initWithJsonDic:(NSDictionary*)jsonDic;
@end
IDTherpayMetaData.h 的代码
#import <Foundation/Foundation.h>
#import "IDTherapyImages.h"
@interface IDTherapyMetadata : NSObject
//Array contains 'String' objects
@property (nonatomic, strong)NSMutableArray* thumbnails;
@property (nonatomic, copy)NSString* title;
@property (nonatomic, copy)NSString* timestamp;
@property (nonatomic, copy)NSString* subCategory;
@property (nonatomic, copy)NSString* lang;
@property (nonatomic, copy)NSString* objId;
@property (nonatomic, copy)NSString* description5;
@property (nonatomic, copy)NSString* description4;
@property (nonatomic, copy)NSString* description3;
@property (nonatomic, copy)NSString* description2;
@property (nonatomic, copy)NSString* description1;
@property (nonatomic, copy)NSString* category;
//Array contains 'IDTherapyImages' objects
@property (nonatomic, strong)NSMutableArray* images;
//methods
-(id)initWithJsonDic:(NSDictionary*)jsonDic;
@end
IDTherapyProducts.h 的代码:
@interface IDTherapyProducts : NSObject
//Array contains 'String' objects
@property (nonatomic, strong)NSMutableArray* contents;
@property (nonatomic, copy)NSString* uniqueId;
@property (nonatomic, copy)NSString* timestamp;
@property (nonatomic, copy)NSString* price;
@property (nonatomic, copy)NSString* posted;
@property (nonatomic, copy)NSString* normalPrice;
@property (nonatomic, copy)NSString* metadata;
@property (nonatomic, copy)NSString* lang;
@property (nonatomic, copy)NSString* objId;
@property (nonatomic, copy)NSString* badge;
//methods
-(id)initWithJsonDic:(NSDictionary*)jsonDic;
@end