jjzjj

ios - 设置对象 :forKey: of NSMutableDictionary overwrites all data in dictionary

for(intcnt=0;cnt我正在尝试从我的iPhone的联系人中创建一个NSMutableDictionary对象。为什么我制作一个NSMutableDictionary类型的对象是因为我需要联系人的索引,而且直接从ABAddressRef类型的对象制作索引看起来并不容易。我还需要做搜索功能..我刚编码的时候没有问题,但调试后唯一的问题让我抓狂。在我将名为fullNameArray的数组和名为tempKey的键应用于namedDictionary之后,我可以发现nameDictionary具有fullNameArray的所有值。所有以前的数据都被覆盖了!在应用fullNameAr

ios - react native 错误 : [__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

我在尝试将数据传递给Obj-C方法时遇到错误。代码如图,Obj-C:RCT_EXPORT_METHOD(connect:(NSDictionary*)params){_connection=[_phoneconnect:paramsdelegate:self];}js:Twilio.connect({To:'+447842111281'});问题源于处理NSDictionary,但是我看不出数据有问题。任何见解将不胜感激。堆栈轨迹如下:Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'***

ios - AFNetworking 上传一个用 forKey 引用的文件

我需要将用户在我的应用中插入的一些信息发送到网络服务器我使用的是ASIHTTPRequest,但我在iOS5上遇到了一些问题,所以我决定转向AFNetworking这是我到目前为止编写的代码...AFHTTPClient*client=[AFHTTPClientclientWithBaseURL:[NSURLURLWithString:@"http://theserver.com/upload.php"]];NSMutableDictionary*parameters=[NSMutableDictionarydictionary];[parameterssetObject:[field

ios - NSObject 不支持 encodeWithCoder?

我第一次使用编码是为了将数据保存在我的应用程序之外。我一直在看的例子说要为自定义类调用[superencodeWithCoder:coder];。我有一个扩展NSObject的类,但收到下面的错误消息。这是因为NSObject是基类,没有什么可编码的吗?Receivertype'NSObject'forinstancemessagedoesnotdeclareamethodwithselector'encodeWithCoder:'-(void)encodeWithCoder:(NSCoder*)coder{[superencodeWithCoder:coder];//

objective-c - 要实现 KVC 验证方法,请覆盖 -(BOOL)validateIvar :error: or -validateValue:forKey:error:?

前者在KVCProgGuide中有所描述,但在与Xcode4.0.2(带有iOS4.3SDK)一起安装的用于SnowLeopard的iOSAPI中缺失,其中列出了后者。这适用于iOS2.0或更新版本。谢谢。 最佳答案 您可以同时使用两者。对于名为foo的键,您可以实现特定方法-(BOOL)validateFoo:(id*)ioValueerror:(NSError**)error{...}或者,一个非特定的方法-(BOOL)validateValue:(id*)ioValueforKey:(NSString*)keyerror:(N

ios - -[__NSCFDictionary setObject :forKey:]: mutating method sent to immutable object

运行以下代码时,[dictsetValue:@"null"forKey:@"name"];一直崩溃。我在这里搜索,发现其他帖子是由不使用NSMutableDictionary的人引起的。但是我正在使用它。如果name为null,为什么会在这一行崩溃?NSMutableArray*tempCustomers=[[NSMutableArrayalloc]init];for(NSMutableDictionary*dictin[[jsonobjectForKey:@"data"]mutableCopy]){if([dictobjectForKey:@"name"]==[NSNullnull]

objective-c - 在 NSMutableDictionary 中是否有一种干净的方法来使用指针 (id) 作为键?

我正在使用NSMutableDictionary来存储某些类的有效描述符,因为我不想浪费将描述符添加到类的每个实例的内存,因为只有1000个对象中的一小部分会有描述符。不幸的是,给出:MyClass*p=[MyClassthingy];NSMutableDictionary*dict=[NSMutableDictionarydictionary];NSString*description=@"blah";//doesthiswork?IfnotI'mjustsimplifyingforthisexample.[dictsetObject:descriptionforKey:p];//B

Objective-C:forKey 和 forKeyPath 有什么区别?

NSMutableDicitionary的setValue方法中的forKey和forKeyPath有什么区别?我在文档中查找了它们,它们对我来说似乎是一样的。我尝试了以下代码,但无法区分其中的区别。NSMutableDictionary*dict=[NSMutableDictionarydictionary];[dictsetValue:@"abc"forKey:@"ABC"];[dictsetValue:@"123"forKeyPath:@"xyz"];for(NSString*keyindict){idval=[dictobjectForKey:key];NSLog(@"%@,%

swift - 自定义类存储 - 无法编码结构

我正在尝试使用UserDefaults存储自定义类的数组。自定义类用于混合使用字符串和CLLocationCoordinate2D的注释。当我在mapView中执行长按手势时,我正在调用ArchiveUtil.savePins(pins:pins)。但是,我收到一个错误-[NSKeyedArchiverencodeValueOfObjCType:at:]:thisarchivercannotencodestructs'知道我做错了什么吗?谢谢,代码如下:classPinLocation:NSObject,NSCoding,MKAnnotation{vartitle:String?var

通用字典类 : cannot invoke 'removeValue' with an argument list of type '(forKey K)' 的 Swift 编译器错误

我创建了一个简单的字典类,用于跨多个线程同步访问字典。我正在使用DispatchQueue来同步从字典中读取和写入值。我正在使用泛型,以便它可以与任何字典类型一起使用K:Hashable作为键,T作为对象。这是一个类的例子:publicclassSynchronizedDictionarywhereK:Hashable{privatevaraccessQueue:DispatchQueue!privatevarinternalDict:[K:T]init(queueName:String){accessQueue=DispatchQueue(label:queueName,qos:.d