0

Trying to send some data form my previous ViewController. To be more clear trying to send the selected date of the Si-Calendar to my secondView.

I'm adding the Calendar to my view in this way:

CalendarMonth *aCalendarView = [[CalendarMonth alloc] initWithFrame:CGRectMake(0, 0, 320, 324) logic:calendarLogic];
[aCalendarView selectButtonForDate:selectedDate];
[self.view addSubview:aCalendarView];

How do I use selected date and send it to my secondViewController (a UIView in which I'll display the selected date)?

el.severo
  • 2,202
  • 6
  • 31
  • 62
  • Sending an object to a view or a controller is syntactical the same. objective-c doesn't know the difference between a view and a controller. this is not an language feature but a pattern. for obj-c it is just passing an object from one object to another. so your question got answered here: http://stackoverflow.com/questions/8243266/how-to-send-a-nsdate-to-another-view – vikingosegundo Nov 28 '11 at 11:36
  • Could you explain the math behind this statement? – vikingosegundo Nov 28 '11 at 11:46

4 Answers4

1

It is a bit unclear what the first or second viewController is, but in general you could use a delegate for this purpose. For an example on how to do this, take a look at this answer

Community
  • 1
  • 1
tilo
  • 14,009
  • 6
  • 68
  • 85
1

Add a date property to your secondViewController, and set it appropriately when you create the instance...

tarmes
  • 15,366
  • 10
  • 53
  • 87
1

There are many ways to exchange data between view controllers, just take them as objects.

  1. first controller hold a ref of the second controller, and transfer data using variables and methods
  2. use delegate,
  3. use notification

etc.

wcrane
  • 1,195
  • 7
  • 18
1

i can see that you are adding the CalenderMonth as the subview to another view. So if you dont release it (until u create the second view controller), you can set the selectedDate of the calender month obj to an iVar of second view controller. Else Create a delegate for CalenderMonth class. Set the second view controller as the delegate of the CalenderMonth and do the necessary.

Shanti K
  • 2,873
  • 1
  • 16
  • 31