简体   繁体   English

无法识别的选择器发送到实例

[英]unrecognized selector sent to instance

sorry guys but i cant get the hang of this array lark.对不起,伙计们,但我无法掌握这个阵列百灵鸟的窍门。 Ive tried everthing to make this work before posting yet another question about arrays.在发布另一个关于数组的问题之前,我已经尝试过一切来完成这项工作。 But i cant help it im really stuck但我无法帮助它我真的卡住了

here goes开始

im simply trying to access a value of a key/value pair :我只是试图访问键/值对的值:

   NSDictionary *itemsInSection  = [self.patternImagesArray objectAtIndex:indexPath.section];
    NSString *groupTitle = [[[itemsInSection allValues] objectAtIndex:1] objectForKey:@"RequestTitle"];

however when attempting to access the groupTitle it crashes with an invalid pointer "RequestTitle" .但是,当尝试访问 groupTitle 时,它​​会因无效指针 "RequestTitle" 而崩溃。 Which i can assure you is there.我可以向你保证在那里。

itemsInSection  __NSCFDictionary *  2 key/value pairs   0x00000001555dc410
[0] struct __lldb_autogen_nspair        
[1] struct __lldb_autogen_nspair        
key __NSCFString *  @"RequestTitle" 0x00000001555be430
value   __NSCFString *  @"Council bill" 0x00000001555db260

The result is fixed and the specific key/value will always appear at position 1 in the dictionary.结果是固定的,特定的键/值将始终出现在字典中的位置 1。

I have also tried numerous variations of this line:我还尝试了这一行的许多变体:

NSString *groupTitle = [[[itemsInSection allValues] objectAtIndex:1] objectForKey:@"RequestTitle"];

and

NSString *groupTitle = [[[itemsInSection allValues] objectAtIndex:1] valueForKey:@"RequestTitle"];

and

NSString *groupTitle = [[itemsInSection][1] objectForKey:@"RequestTitle"];

to name just a few.仅举几例。

An NSDictionary is an association of key/value pairs: a given key within the dictionary is unique. NSDictionary 是键/值对的关联:字典中的给定键是唯一的。

Your NSDictionary (from your output) contains a key called "RequestTitle".您的 NSDictionary(来自您的输出)包含一个名为“RequestTitle”的键。 If you want to retrieve the value associated with that key, try:如果要检索与该键关联的值,请尝试:

NSString *groupTitle = [itemsInSection objectForKey:@"RequestTitle"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM