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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:28:11+00:00 2026-05-22T20:28:11+00:00

Checkin *checkinsA = [[Checkin alloc] init]; NSDictionary *decodedJson = result; NSArray *users = [decodedJson

  • 0
Checkin *checkinsA = [[Checkin alloc] init]; 

NSDictionary *decodedJson = result;
NSArray *users = [decodedJson objectForKey:@”data”];
Checkin *test = [[Checkin alloc] init];

for(NSDictionary *user in users) {
    NSLog(@"Created item: %@ \n", [user objectForKey:@"created_time"]);
     checkinsA.time = [NSString stringWithFormat:@"%@",[user objectForKey:@"created_time"]];
    NSDictionary *fromData = [user objectForKey:@"from"];
     NSLog(@"user id is: %@ \n", [fromData objectForKey:@"id"]);
      checkinsA.profID = [fromData objectForKey:@"id"];

     NSLog(@"user name is: %@\n ", [fromData objectForKey:@"name"]);
      checkinsA.name =[fromData objectForKey:@"name"];

    NSDictionary *placeData = [user objectForKey:@"place"];
    NSDictionary *locationData = [placeData objectForKey:@"location"];
     NSLog(@"City: %@ \n", [locationData objectForKey:@"city"]);
      checkinsA.city = [locationData objectForKey:@"city"];

     NSLog(@"Country: %@ \n", [locationData objectForKey:@"country"]);
      checkinsA.country = [locationData objectForKey:@"country"];

     NSLog(@"Latitude: %@ \n", [locationData objectForKey:@"latitude"]);
     checkinsA.lat = [locationData objectForKey:@"latitude"];

     NSLog(@"Longitude: %@ \n", [locationData objectForKey:@"longitude"]);
     checkinsA.lon = [locationData objectForKey:@"longitude"];

     NSLog(@"Place name: %@ \n", [placeData objectForKey:@"name"]);
     checkinsA.place = [placeData objectForKey:@"name"];

    NSDictionary *tagData = [user objectForKey:@"tags"];
    NSArray *tagDataArray = [tagData objectForKey:@"data"];
    for(NSDictionary *tagData2 in tagDataArray){
      NSLog(@"tagged user id is: %@ \n", [tagData2 objectForKey:@"id"]);
        [checkinsA.taggedID addObject:[tagData2 objectForKey:@"id"]];
      NSLog(@"tagged user name is: %@\n ", [tagData2 objectForKey:@"name"]);
         [checkinsA.taggedName addObject:[tagData2 objectForKey:@"name"]];
    }

    [checkinArray addObject:checkinsA];
    test = [checkinArray objectAtIndex:count2];
    NSLog(@"Check array: %@",test.name);
    count2++;
}
for(int i=0;i<count2;i++)
{
    test = [checkinArray objectAtIndex:i];
    NSLog(@"%@",test.name);
}

}

My NSobject is the CheckinsA. I am collecting data from a response string using NSDictionary. What I am trying to do here is to save each CheckinsA in a the checkinArray.This looks fine:

`[checkinArray addObject:checkinsA];

test = [checkinArray objectAtIndex:count2];

NSLog(@"Check array: %@",test.name);`

and is printing the right value. But when the loop is finished and I am trying to print the values from the array using a loop is printing out only the last CheckinsA!! I tried to print it with:

test = [checkinArray objectAtIndex:0];
NSLog(@"%@",test.name);
test = [checkinArray objectAtIndex:1];
NSLog(@"%@",test.name);

(just in case that my loop was the problem but its still printing only the last CheckinsA).
So why my whole array is filled only with the last CheckinsA? It’s weird!

  • 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-22T20:28:11+00:00Added an answer on May 22, 2026 at 8:28 pm

    You need to initialize a new object every time you loop. Otherwise you are changing the same object.

    make Checkin *checkinsA = [[Checkin alloc] init]; the first line in the loop and at the end after you are done adding checkinsA to the array, do [checkinsA release];

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

Sidebar

Related Questions

Is there a way to find out the checkin history of a user in
Check it: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSLog(@Checking login--user value is %@, [defaults valueForKey:@userID]);
I've always found checkin (commit) mails to be very useful for keeping track of
I have installed StyleCop CheckIn policy (from here ) and it works great. However
I'm using Subversion to checkin a file on OSX. I have my EDITOR variable
How do I generate a default comment for cvs? I'd like every checkin comment
I have the following setup webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; Occasionally I issue
So I am trying to save arrays into an NSDictionary on the fly. Let
i have this: - (IBAction)checkupdate { statusText.text = [[NSString alloc] initWithFormat:@Checking......]; everytime i press
I'm having a really confounding problem using Core Data. In my Core Data store,

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.