Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8974805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:44:58+00:00 2026-06-15T18:44:58+00:00

It seems like I have a problem and don’t know if I’m doing this

  • 0

It seems like I have a problem and don’t know if I’m doing this right since I’m just starting objective c.

Right now I have two files

Stores.h

#import<Foundation/Foundation.h>
#import<MapKit/MapKit.h>

@interface Stores: NSObject

@property(nonatomic,strong) NSString *storeName;
@property(nonatomic,strong) NSMutableArray *MenuItems;

@end

Stores.m

#import "Stores.h"

@synthesize storeName,MenuItems;

@end

Menu.h

#import<Foundation/Foundation.h>


@interface Menu: NSObject

@property(nonatomic,strong) NSString *MenuItemDescription;
@property(nonatomic) int MenuItemPrice;

@end

Menu.m

#import "Menu.h"

@synthesize MenuItemDescription,MenuItemPrice;

@end

ViewController.m

#import "ViewController.h"
#import "Stores.h"
#import "Menu.h"

@interface ViewController ()

@end

@implementation ViewController

NSMutableArray *stores;

-(void) viewDidLoad
{
  [super viewDidLoad];

  stores = [[NSMutableArray alloc]init];

  Stores *store = [[Stores alloc]init];

  [store setStoreName:@"Store1"];
  Menu *menuItem = [[Menu alloc]init];
  [menuItem setMenuItemDescription:@"Item1"];
  [menuItem setMenuItemPrice: 7]

  [store.MenuItems addObject:menuItem]; //won't add menuItem to store.MenuItems

  [stores addObject:store]; 

}

@end

So it doesn’t end up adding any object to store.
If I run it in debug it says that MenuItems has zero objects.
I know I’m doing something wrong but like I said I’m new to iOS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:44:58+00:00Added an answer on June 15, 2026 at 6:44 pm

    You did not (at least in the code you show) alloc/create/assign MenuItems, so it will still be nil. Calling addObject (or anything) on nil is just a no-op.

    Try this

     Stores *store = [[Stores alloc]init];
     store.MenuItems = [NSMutableArray arrayWithCapacity: 10];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a simple problem: I have a WF4 activity that guides the
I have an issue that seems like very flaky behavour, is this a problem
I have a problem with using the prefix, seems like whenever I use the
I have what seems like a simple problem. I have a Spring web app,
This seems like a must have form input for a mobile ui framework, but
I have a problem - I don't know the amount of data being sent
I have problem with connecting to Sql Server from my local machine. Seems like
Does anyone ever have problem like this?? The Enter , Tab , and space
It seems like this title has been used many times before, unfortunately I don't
I have the following problem and don't know how to code it in R:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.