jjzjj

NSMutableDictionary

全部标签

ios - 核心数据不保存可转换的 NSMutableDictionary

我有两个类:配置文件和配置。Profile包含Config对象的NSSet。Profile和Config都是NSManagedObject的子类。@interfaceProfile:NSManagedObject@property(nonatomic,retain)NSString*name;@property(nonatomic,retain)NSSet*configs;-(void)print;@end这是配置类@interfaceConfig:NSManagedObject@property(nonatomic,retain)NSString*otherdata;@propert

iphone - 为什么 NSMutableDictionary 不想写入文件?

-(void)viewDidLoad{[superviewDidLoad];if([[NSFileManagerdefaultManager]fileExistsAtPath:pathString]){infoDict=[[NSMutableDictionaryalloc]initWithContentsOfFile:pathString];}else{infoDict=[[NSMutableDictionaryalloc]initWithObjects:[NSArrayarrayWithObjects:@"BeginFrame",@"EndFrame",nil]forKeys:[NS

objective-c - 如何将 “bool” 值存储在 NSMutableArray* 或 NSMutableDictionary* 中?以 bool 形式传入的 JSON 数据的长期问题

这个问题类似于:Howdoyoustore"int"valuesinanNSMutableArray*orNSMutableDictionary*?ChronicproblemswithJSONdatathatcomeinasintegers.如何使用bool值来做到这一点?如何在NSMutableArray*或NSMutableDictionary*中存储“bool”值?作为bool值传入的JSON数据的长期问题。 最佳答案 您可以将其存储为数字:[mutableArrayaddObject[NSNumbernumberWithB

iphone - iOS, NSMutableDictionary

我在我的项目中遇到了一个问题,我在头文件中声明了一个NSMutableDictionary属性,如下所示:@property(copy,nonatomic)NSMutableDictionary*DataDict;现在在实现文件中,我继续初始化这个字典,因为我要使用它,就像这样:DataDict=[[NSMutableDictionaryalloc]init];现在,当我这样做时,当我尝试向该词典添加内容时,我会收到此错误消息:-[__NSDictionaryIsetObject:forKey:]:unrecognizedselectorsenttoinstance0x885ae602

iphone - 静态 NSMutableDictionary

我想使用静态NSMutableDictionary。能否请您帮助如何在类里面使用静态NSMutableDictionary。这样做对吗?.h文件+(NSMutableDictionary*)contactsToAssignBill;+(void)setContactsToAssignBill:(NSMutableDictionary*)value;.m文件staticNSMutableDictionary*contactsToAssignBill;+(NSMutableDictionary*)contactsToAssignBill{if(!contactsToAssignBill)c

ios - NSMutableDictionary 增删改 KVO

我有一个关于KVO的快速问题。我知道对于NSArray如果需要观察添加,您可以执行以下操作。NSIndexSet*set=[NSIndexSetindexSetWithIndex:[someIndexintegerValue]];[selfwillChange:NSKeyValueChangeInsertionvaluesAtIndexes:setforKey:@"theArrayName"];//addtheobjectsatthespecifiedindexeshere[selfdidChange:NSKeyValueChangeInsertionvaluesAtIndexes:s

Objective-c - 在静态 NSMutableDictionary 上使用 NSCache 的好处?

因此NSCache对象应该保持事件状态以保留缓存数据,这意味着必须使用用于存储数据的同一个对象来检索数据。所以问题是在保存我的数据的单例NSDictionary上使用NSCache有什么意义?使用NSCache的首选方法是什么?静态场?继承它并创建一个单例? 最佳答案 缓存有许多怪癖,使其可以很好地用作缓存,但不太适合用作通用集合。如文档中所述:NSCacheobjectsdifferfromothermutablecollectionsinafewways:TheNSCacheclassincorporatesvariousaut

iphone - 如何从 nsmutabledictionary 中删除键当该键的值在 ios 中为空或 null 时?

我已经创建了NSMutableDictionary,键的值形成为nsarray。我已经删除了键的对象。我对这个案子毫无疑问。但是我想在该键的值为空或null时删除键,如下所示。{Africa=("Kenya","SouthAfrica");America=();Asia=("India");}上面的字典有三个键,其中一个键没有对象是America。我想删除这把key。可能吗?我们可以从nsmutabledictionary中删除键吗?请帮帮我......已编辑:简单的错误。我明白我弄错了什么。key(America)有值,它是空数组,这意味着数组中的元素数为零。

ios - 无法将类型 'NSMutableDictionary' 的值转换为预期的参数类型 '[String: AnyObject]?'

我想跳过去使用Xcode7.3.1并转换我的代码,但我在这里遇到了某种问题,这就是我过去在Swift1.1中使用它的方式,但我收到错误-无法转换值类型为“NSMutableDictionary”的预期参数类型为“[String:AnyObject]?”:privatefuncgetPlacemark()->CLPlacemark{varaddressDict=NSMutableDictionary()varformattedAddressArray=self.formattedAddress.componentsSeparatedByString(",")asArrayletkSubA

ios - 找不到成员 'setObject' : NSMutableDictionary

我已将变量声明为varoptionDictionary:NSMutableDictionary!尝试在函数中为该变量设置对象,但出现错误Couldnotfindmember'setObject'funcsetOptionSetting(){self.optionDictionary=NSMutableDictionary()//NoErrorself.optionDictionary!.setObject(NSNumber(int:Integer_Constant)!,forKey:"Key_Constant")//here,Igoterror......}请任何人找到这个,请用简短的