Ios NSCFString objectAtIndex无法识别的选择器已发送到实例0xc16bad0

Ios NSCFString objectAtIndex无法识别的选择器已发送到实例0xc16bad0,ios,objective-c,Ios,Objective C,这是我的密码: NSArray *items = [[NSArray alloc] initWithArray:CatTitle]; NSLog(@"%@",items); menu = [[BlurMenu alloc] initWithItems:items parentView:self.view delegate:self]; NSLog(@"I'm here !"); isMenuCat = TRUE; [menu show]; 当NSLog

这是我的密码:

NSArray *items = [[NSArray alloc] initWithArray:CatTitle];

    NSLog(@"%@",items);
    menu = [[BlurMenu alloc] initWithItems:items parentView:self.view delegate:self];
    NSLog(@"I'm here !");
    isMenuCat = TRUE;
    [menu show];
NSLog“项目”获得结果时:

( “\U0627\U0646\U0642\U0637\U0627\U0639\U062c\U0632\U0626\U064a”, “\U0627\U0646\U0642\U0637\U0627\U0639\U0643\U0644\U064a”, “\U062d\U0631\U064a\U0642”, “\U0645\U0634\U0643\U0644\U0629\U062e\U0627\U0635\U0629\U0628\U0627\U0644\U062c\U0647\U062f” )

我正在使用创建模糊菜单的库,在
BlurMenu.m
文件中:

- (id)initWithItems:(NSArray*)items parentView:(UIView *)p delegate:(id<BlurMenuDelegate>)d {
    self = [super init];

    if (self) {

        int i = 0;
        NSMutableArray *temp_Arr = [[NSMutableArray alloc]init];
        for (NSArray *xx in items) {
            [temp_Arr addObject:[xx objectAtIndex:i]];
            NSLog(@"%@",[xx objectAtIndex:i]);
            i++;
        }

        userData = [NSUserDefaults standardUserDefaults];
        [userData setBool:NO forKey:@"isTwice"];
        [userData synchronize];

        self.parent = p;
        self.delegate = d;
        self.menuItems = temp_Arr;

        self.alpha = 0.0f;
        self.frame = p.frame;

        UIImage *background = [self blurredSnapshot];
        UIImageView *backgroundView = [[UIImageView alloc] initWithImage:background];
        [self addSubview:backgroundView];

        CGFloat height = [self calculateCollectionViewHeight];

        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        [layout setMinimumLineSpacing:ITEM_LINE_SPACING];
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, (self.frame.size.height - height) / 2, self.frame.size.width, height) collectionViewLayout:layout];
        [_collectionView setDataSource:self];
        [_collectionView setDelegate:self];
        [_collectionView registerClass:[BlurMenuItemCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
        [_collectionView setBackgroundColor:[UIColor clearColor]];
        [self addSubview:_collectionView];

        UIButton *close = [UIButton buttonWithType:UIButtonTypeCustom];
        close.frame = CGRectMake(0, self.frame.size.height - COLLECTION_VIEW_PADDING, self.frame.size.width, COLLECTION_VIEW_PADDING);
        close.backgroundColor = [UIColor clearColor];
        [close setTitle:@"Close" forState:UIControlStateNormal];
        [close setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        close.titleLabel.font = [UIFont fontWithName:@"GillSans-Light" size:18.0f];
        [close addTarget:self action:@selector(hide) forControlEvents:UIControlEventTouchDown];
        [self addSubview:close];

    }
    return self;
}
以下是错误:

-[\uu NSCFString objectAtIndex:]:发送到实例0xc16bad0的选择器无法识别 ***由于未捕获异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\u NSCFString objectAtIndex:]: 已将无法识别的选择器发送到实例0xc16bad0'


正如
项的
NSLog
所示,
CatTitle
是一个字符串数组;因此,当您将其传递到
initWithItems:
并使用此循环访问其内容时

int i = 0;
NSMutableArray *temp_Arr = [[NSMutableArray alloc]init];
for (NSArray *xx in items) {
    [temp_Arr addObject:[xx objectAtIndex:i]];
    NSLog(@"%@",[xx objectAtIndex:i]);
    i++;
}
您将其视为数组的数组,但由于“xx”实际上不是数组而是字符串,因此它会导致您收到的
NSInvalidArgumentException

因此,您可以尝试使用循环将字符串添加到
temp\u Arr

NSMutableArray *temp_Arr = [[NSMutableArray alloc]init];
for (NSString *xx in items) {
    [temp_Arr addObject:xx];
    NSLog(@"%@", xx);
}
但实际上,这是不必要的,因为您只需使用一行代码即可将
数组复制到
temp_Arr

NSMutableArray *temp_Arr = [[NSMutableArray alloc] initWithArray:items copyItems:YES];

指出给出错误的那一行。但错误是显而易见的。您有一个
NSString
实例,其中您的代码假设有一个
NSArray
@rmaddy,我指向它。。提前谢谢,这不可能是电话线。它很可能是
initWithItems:parentView:delegate:
方法内for循环的第1行。这是一种类型的行,因为这是初始化BlurMenu并触发包含其他代码的initWithItems:方法的地方。。。但是,是的,循环中的xx可能是一个字符串,并导致了错误。实际上,它肯定是一个字符串,在你的NSLog中很明显。
NSMutableArray *temp_Arr = [[NSMutableArray alloc] initWithArray:items copyItems:YES];