美文网首页
iOS indexOfObject使用

iOS indexOfObject使用

作者: 搬码小能手 | 来源:发表于2019-12-19 20:35 被阅读0次

    -(NSUInteger)indexOfObject:(ObjectType)anObject;

    点击这里官方文档
    Return Value
    The lowest index whose corresponding array value is equal to anObject.
    If none of the objects in the array is equal to anObject, returns NSNotFound.

    
    [[NetworkTool managerTool] requesNoHud:POST UrlString:[HttpInterface getJinTiKuProfession] parameters:mdict finished:^(id result, NSError *error) {
            if (result) {
                if ([[result objectForKey:@"success"]boolValue]) {
                    NSDictionary * info = [result objectForKey:@"entity"][@"info"];
                    self.infoModel = [WJSubjectCategoryModel mj_objectArrayWithKeyValuesArray:info];
                    
                    [self.leftTableView reloadData];
                    [self.rightTableView reloadData];
                    
                    NSMutableArray * mArray = [[NSMutableArray alloc]init];
                    // 遍历self.infoModel数组,把status的值拿出来,存入数组
                    for (WJSubjectCategoryModel * model in self.infoModel) {
                        [mArray addObject:model.status];
                    }
                    // The lowest index whose corresponding array value is equal to anObject. If none of the objects in the array is equal to anObject, returns NSNotFound.
                    // 对应数组值等于一个对象的最低索引
                    NSUInteger index = [mArray indexOfObject:@"0"];
    //                if (index == NSNotFound) {
    //                    index = 0;
    //                }
                    
                    [self.leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]
                                                       animated:YES
                                                 scrollPosition:UITableViewScrollPositionNone];
                }else{
                    [MBProgressHUD showError:[result objectForKey:@"message"]];
                }
            }else{
                [MBProgressHUD showError:@"格式错误"];
            }
            
        }];
    

    相关文章

      网友评论

          本文标题:iOS indexOfObject使用

          本文链接:https://www.haomeiwen.com/subject/abevnctx.html