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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:31:52+00:00 2026-05-20T09:31:52+00:00

I am doing a small concept on NSMutableDictionary. I have four keys (Name, Age,

  • 0

I am doing a small concept on NSMutableDictionary.
I have four keys (Name, Age, PhoneNumber, Gender) for 10 employees.

How can I assign these values to an array?

Individually I passed 4 different values for the dictionary but the fourth value is coming repeatedly.
this is the code what i have written
– (void)viewDidLoad {

NSLog(@"in mytableviews viewdidload");



  EmpArray=[[NSMutableArray alloc]init];





//namesArray=[[NSMutableArray alloc]initWithObjects:@"jam",@"jack",@"gillchrist",@"jackson"];


  EmpDictionary=[[NSMutableDictionary alloc]init];
 [EmpDictionary setValue:@"martin" forKey:@"name"];
 [EmpDictionary setValue:@"18" forKey:@"age"];
 [EmpDictionary setValue:@"M" forKey:@"gender"];
 [EmpDictionary setValue:@"9652893070" forKey:@"phoneNumber"];
    [EmpArray addObject:EmpDictionary];
NSLog(@"emparray counr %d",[self.EmpArray count]);



[EmpDictionary setValue:@"jack" forKey:@"name"];
[EmpDictionary setValue:@"19" forKey:@"age"];
[EmpDictionary setValue:@"F" forKey:@"gender"];
[EmpDictionary setValue:@"96656893070" forKey:@"phoneNumber"];
[EmpArray addObject:EmpDictionary];

[EmpDictionary setValue:@"Louis" forKey:@"name"];
[EmpDictionary setValue:@"21" forKey:@"age"];
[EmpDictionary setValue:@"F" forKey:@"gender"];
[EmpDictionary setValue:@"9652893060" forKey:@"phoneNumber"];
[EmpArray addObject:EmpDictionary];

[EmpDictionary setValue:@"Gillchrist" forKey:@"name"];
[EmpDictionary setValue:@"23" forKey:@"age"];
[EmpDictionary setValue:@"M" forKey:@"gender"];
[EmpDictionary setValue:@"99998989" forKey:@"phoneNumber"];
 [EmpArray addObject:EmpDictionary];


 [super viewDidLoad];

}

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

NSLog(@"creating cell in cell for row at index"); 

employeeCell *empcell = (employeeCell *)[tableView dequeueReusableCellWithIdentifier:@"empcell1"];

if(empcell==nil)
{
    NSLog(@"In creating cell");
    [[NSBundle mainBundle]loadNibNamed:@"employeeCell" owner:self options:nil];
    empcell=tableCell;
}

for(int i=1;i<=3;i++)
{

    NSLog(@"after creating cell");

    //NSDictionary *temp=[self.EmpArray objectAtIndex:indexPath.row];
NSDictionary *temp = [self.EmpArray objectAtIndex:indexPath.row];
NSString *empname= [temp objectForKey:@"name"];
NSString *age= [temp objectForKey:@"age"];
//NSInteger age = [temp objectForKey:@"age"];
NSString *gender= [temp objectForKey:@"gender"];
NSString  *phonenumber = [temp objectForKey:@"phoneNumber"];

empcell.EmpName.text=empname;

empcell.EmpAge.text=age;

 empcell.EmpGender.text=gender;
empcell.EmpPhoneNumber.text=phonenumber;


empcell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
return empcell;

}

  • 1 1 Answer
  • 1 View
  • 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-20T09:31:53+00:00Added an answer on May 20, 2026 at 9:31 am

    You’re going to want to either create new dictionaries for each set of entries you want to add or do

    [[EmpArray addObject:[EmpDictionary copy]];
    

    Otherwise, you’re just adding the same object 4 times, so your end result show 4 cells with the same information in them. Your end array is not 4 different objects, just 4 pointers to the same object.

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

Sidebar

Related Questions

While doing some small regex task I came upon this problem. I have a
I'm doing a small app in Excel, and I have the following code when
i am doing one small application , wheich have login functionality, in the user
I have decided to start doing small coding projects on my own that focus
Just doing a small project relating to google maps. Basically I have coordinates in
i am doing a small on concept on how to add label to scrollview
Say I have a simple model like these (small part of a pretty large
i doing a small project in django by using python. In that admin can
I am doing small Silverlight app which will allow users to Create orders. I
I'm doing jquery small animation of fade in to form validation This is working

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.