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 a .Net object (in C#) which has properties named event1, event2 and
I have class A, which exposes an event. an object of class B subscribed
I need to have some object hanging around between two events I'm interested in:
I have a question regarding events in c#. Lets say I have an object
I have an object with event handlers and I want to make something similar
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 a onclick event that is like: public void OnMyButton_Click(object sender, EventArgs e)
I have a StatusChanged event that is raised by my object when its status
I have an XmlSerializer object, and I have added 2 event handlers to 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.