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

  • Home
  • SEARCH
  • 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 6171547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:14:04+00:00 2026-05-23T23:14:04+00:00

I have an events object which is given below NSString *name; NSString *date; NSInteger

  • 0

I have an events object which is given below

NSString *name;
NSString *date;
NSInteger id;

I am storing the events object in a NSMutabelArray. I want to add to the date and store in a different array. For that I am using the code below

NSString *curDate = event.Date;
NSDate *date = [dateFormat dateFromString:curDate];
for(int i=0;i<5;i++)
{
  Events *newEvent = event;
  NSDate *newDate = [date dateByAddingTimeInterval:60*60*24*1];
  newEvent.date = [dateFormat stringFromDate:newDate];
  [deleg.events addObject:newEvent];
  date = newDate;
}

So after final iteration of loop all the objects in deleg.events is having the last calculated date. How can I resolve it.
Thanks

  • 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-23T23:14:06+00:00Added an answer on May 23, 2026 at 11:14 pm

    You’re not making a new event. Your line

    Events *newEvent = event;
    

    is just creating a new variable that references the exact same event object, which means you now have added the exact same object to the array 5 times.

    I don’t know how your Events class works. If it conforms to NSCopying, then you can use

    Events *newEvent = [[event copy] autorelease];
    

    If not, you’ll have to create a brand new Events object (using [[Events alloc] init] or whatever is appropriate for the class) and populate it with the appropriate data.

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

Sidebar

Related Questions

I have an Events table whose goal is to store actions done by web
rbnResubmission.Items.FindByValue(Yes).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); rbnResubmission.Items.FindByValue(No).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); So I have these click events for showing rows in
I have an object which is derived from DependencyObject with multiple DependencyProperties. This object
I have a working Browser Helper Object (BHO) which is essentially an ATL based
I have this routine which is called onmouseover of a certain element. I want
I have a basic domain object, say like Person or Campaign or Event that
For my Django app I have Events, Ratings, and Users. Ratings are related to
I have an Events list in sharepoint and need to disallow users from having
I have a table of events with a recorded start and end time as
I have a table of events, I need to find all tail events of

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.