1

I am developing an iOS app.NSMutableArray value Not Pass on NSArray.This Array can be count on table view

 - (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 = @"[email protected]";
    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
  • NSMutableArray *array; change this to NSMutableArray *array =[ [NSMutableArray alloc]init]; let me know Commented Oct 13, 2015 at 6:15

1 Answer 1

1

You have to alloc init NSMutableArray

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

then only value can stored in array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.