MutableArray值未在数组上传递

时间:2015-10-13 06:10:54

标签: ios objective-c nsmutablearray

我正在app.NSMutableArray开发iOS NSArray值Not Pass。此数组可以依赖于表格视图

 - (NSArray *)menuArray
    {

        NSMutableArray *array = [[NSMutableArray alloc]init];

        if (_selectionType == BBSelectionBoat || _selectionType == BBSelectionOtherBoat || _selectionType == BBlatestBoat)
        {
            BBMenu *menu = [[BBMenu alloc]initWithTableName:@"MenuBoatBrat"];
            array = [menu buldMenu];

            BBMenuEntry *menuentry = [[BBMenuEntry alloc]init];
            menuentry.menuID = -1;
            menuentry.catID = -1;
            menuentry.caption = @"Boat Sales";
            menuentry.subMenus = nil;

            [array insertObject:menuentry atIndex:0];

            menuentry = [[BBMenuEntry alloc]init];
            menuentry.menuID = -1;
            menuentry.catID = -1;
            menuentry.caption = @"Latest Boat Sales";
            menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:1];

    }
    else if (_selectionType == BBSelectionMarine || _selectionType == BBSelectionOtherMarine || _selectionType == BBlatestMarine)
    {
        BBMenu *menu = [[BBMenu alloc]initWithTableName:@"MenuMarine"];
        array = [menu buldMenu];

        BBMenuEntry *menuentry = [[BBMenuEntry alloc]init];
        menuentry.menuID = -1;
        menuentry.catID = -1;
        menuentry.caption = @"Marine Directory";
        menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:0];

        menuentry = [[BBMenuEntry alloc]init];
        menuentry.menuID = -1;
        menuentry.catID = -1;
        menuentry.caption = @"Latest Marine";
        menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:1];

    }else if ( _selectionType == BBSelectionUpcomingEvents || _selectionType == BBSelectionOtherUpcomingEvents || _selectionType == BBSelectionEvents )
    {
        BBMenu *menu = [[BBMenu alloc]initWithTableName:@"MenuEvents"];
        array = [menu buldMenu];

        BBMenuEntry *menuentry = [[BBMenuEntry alloc]init];
        menuentry.menuID = -1;
        menuentry.catID = -1;
        menuentry.caption = @"Upcoming Events";
        menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:0];


    }else if (_selectionType == BBSelectionGrabAotherDeals || _selectionType == BBSelectionGrabADeal || _selectionType == BBSelectiondeal )
    {
        BBMenu *menu = [[BBMenu alloc]initWithTableName:@"MenuDeals"];
        array = [menu buldMenu];
        BBMenuEntry *menuentry = [[BBMenuEntry alloc]init];
        menuentry.menuID = -1;
        menuentry.catID = -1;
        menuentry.caption = @"Marine Deal";
        menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:0];

        menuentry = [[BBMenuEntry alloc]init];
        menuentry.menuID = -1;
        menuentry.catID = -1;
        menuentry.caption = @"Latest Deals";
        menuentry.subMenus = nil;

        [array insertObject:menuentry atIndex:1];

    }

    BBMenuEntry *menuentry = [[BBMenuEntry alloc]init];

    menuentry.menuID = -1;
    menuentry.catID = -1;
    menuentry.caption = @"Home";
    menuentry.subMenus = nil;

    [array insertObject:menuentry atIndex:0];


    menuentry = [[BBMenuEntry alloc]init];

    menuentry.menuID = -1;
    menuentry.catID = -1;
    menuentry.caption = @"+61 290 98 4818";
    menuentry.subMenus = nil;

    [array addObject:menuentry];

    menuentry = [[BBMenuEntry alloc]init];

    menuentry.menuID = -1;
    menuentry.catID = -1;
    menuentry.caption = @"support@boatbrat.com";
    menuentry.subMenus = nil;

    [array addObject:menuentry];

    _menuArray = [NSArray arrayWithArray:array];

    return  _menuArray;
    }




 array Value Has some objects.but sign array value to _menuArray. show zero objects on _menuArray.

1 个答案:

答案 0 :(得分:1)

你必须分配init NSMutableArray

NSMutableArray *array = [[NSMutableArray alloc]init];

然后只有值可以存储在数组