1
我正在開發一款iOS app.NSMutableArray
值上NSArray
。這不通過陣列可以在表視圖指望MutableArray價值不及格的陣列
- (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.
NSMutableArray * array;將其更改爲NSMutableArray * array = [[NSMutableArray alloc] init];讓我知道 – Spynet