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 7083905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:14:10+00:00 2026-05-28T07:14:10+00:00

Unable to add NSmutableDictionary in NSmutableArray, activitiesFeedArray is a mutable array and initialized in

  • 0

Unable to add NSmutableDictionary in NSmutableArray, activitiesFeedArray is a mutable array and initialized in header file.

            NSMutableDictionary *dummyitem = [[NSMutableDictionary alloc]init];
            NSMutableDictionary *dummyitem2 = [[NSMutableDictionary alloc]init];
            NSMutableDictionary *dummyitem3 = [[NSMutableDictionary alloc]init];

            [dummyitem setObject:@"No Data Found" forKey:@"text"];
            [dummyitem2 setValue:dummyitem forKey:@"Title"];
            [dummyitem3 setObject:dummyitem2 forKey:@"ItemInfo"];

            NSLog(@"%@",dummyitem3);

            //dummyitem3 logs correct value here             

            if ([activitiesFeedArray count] == 0) 
            { 
                NSLog(@"%@",dummyitem3);
                //dummyitem3 logs correct value here
                [activitiesFeedArray addObject:dummyitem3];
                NSLog(@"%@",activitiesFeedArray);
                //activitiesFeedArray logs null value here
            }

Viewdid load

    (void)viewDidLoad
{
   [super viewDidLoad];
   activitiesFeedArray = [[NSMutableArray alloc]init];
}

Header File

@interface SearchViewController : UIViewController <UISearchBarDelegate ,UITableViewDelegate , UITableViewDataSource>
{
  NSMutableArray *activitiesFeedArray;
}
@end
  • 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-05-28T07:14:11+00:00Added an answer on May 28, 2026 at 7:14 am

    If this is the only code you have, then it should work fine and NSLog of your NSMutableArray should not return nil. I copied and pasted your code on my XCode and it works perfectly. You must be doing something somewhere else in your code to alter NSMutableArray.


    If you are curious what I did to prove that your code works, I created a simple UIViewController with one button in it. I then created a UIViewController class and literally copied your code in the header file and the implementation file. I declared the NSMutableArray in the header file and initialized it in viewdidload (I copied and pasted them as is). I also put the rest of your NSMutableDictionary code in the viewDidLoad and it produced sensible results. The NSMutableArray log shows that it contains the correct data.

    Sometimes it helps to do a clean build but as far as I can tell you, your code is correct and should work.

    By the way, I have IOS5 and XCode 4.2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unable to add an mdf database file by right clicking on the project
Error : Unable to add cookies, header already sent. I would like to know
Am unable to add elements to a dropdown list via Javascript. The below piece
I have a problem in using Entity data model. I'm unable to add a
Im trying to add objects to an array by using push. I have a
I have the following code working fine, but I'm unable to add a zoom
set a UIImageView.image property to a UIImage is unable add the image to the
i created a text-box through the code behind but was unable to add a
please help me with this this is really erratic I am unable to add
Im unable to add a reference to System.Data.Linq to my project, I get the

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.