簡體   English   中英

MutableArray值未在數組上傳遞

[英]MutableArray Value Not Passing on array

我正在開發一個iOS app.NSMutableArray值Not Pass on NSArray 。此Array可以在表視圖中計數

 - (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.

您必須分配初始化NSMutableArray

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

那么只有值可以存儲在數組中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM