如何从NSMutableArray中获取String值

Sha*_*ief 0 string iphone nsmutablearray didselectrowatindexpath

码:

[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
                                       NSLocalizedString(@"PropertySubtype2fTitle", @""), 
                                       kTitleKey,
                                       publishNoOfRoomsViewController, 
                                       kViewControllerKey, nil]];
Run Code Online (Sandbox Code Playgroud)

menuList是一个NSMutableArray.

我想稍后在代码中读取PropertySubtype2fTitle本地化字符串,如:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

Til*_*ill 8

要从NSDictionary中获取条目,您可以使用

[NSDictionary objectForKey:(id)keyValue]
.要从NSArray/NSMutableArray中获取条目,您可以使用
[NSArray objectAtIndex:(NSUInteger)index]
.组合并应用于您的示例应该是:
NSString *title = [[menuList objectAtIndex:index] objectForKey:kTitleKey];
而index是无符号整数(NSUInteger).