1

I have a UITableView (let’s say class “Parent” which is in view "screen 1"). When I click on one of the Parent’s cell's, I’m displaying another UITableView (let’s call it class “child” in view “Screen2”). Parent and child are connected through “segue” and I’m able to pass the data using “segue”.

For example, parent is having cell – “Cell1” and on touch “Cell1”, I’m getting “Cell11”,”Cell12”,”Cell13” [this is “screen2, table view object”].

Now, there are some descriptions associated with “Cell11” (Once I touched “Cell11”) and i'd like it to display Cell11’s description in another view controller (“screen3”). Here, to pass information between “screen2” to “screen3” I'd rather not to use a “Segue”.

How can I do this?

Bejmax
  • 945
  • 7
  • 16
AskMe
  • 2,495
  • 8
  • 49
  • 102
  • You, just need to maintain array with properties and in another class, just take the object of previous class and from this object you can retrieve the array.Try to maintain your array as such so you can retrieve the value depends on the index as of tableView Row index.In case, if you want this logic to many class, then maintain a base class with dictionary, and derived all controller from this class(BaseClass), and in which controller you need to store value(s), just maintain array and save that array in base class dictionary.:) – Mohit_Jaiswal Dec 10 '12 at 12:37
  • I'm new to this development.I was thinking about same logic.But having prblem in implementing.Plaese give any sample code for this.Thanks – AskMe Dec 10 '12 at 12:40
  • If you do not want to use a segue to show "screen3", how do you intend to show it? – Phillip Mills Dec 10 '12 at 12:41
  • Any other way without Segue.I refered this: http://www.leesilver.net/1/post/2011/08/passing-data-between-view-controllers-in-objective-c.html But,no success after implementation. – AskMe Dec 10 '12 at 12:43
  • Sure, I'll but not yet as have to attend some important meeting. Meanwhile, you try and I hope you can do. :) – Mohit_Jaiswal Dec 10 '12 at 12:47
  • Mean-time, instead of doing it from base class just use the each class array approach. You'll find it easier. Bye..:) – Mohit_Jaiswal Dec 10 '12 at 12:48
  • Ok, just do it like, say in class A: At.h->@property(strong)NSMutableArray myArrayA; At .m-> myArrayA *objA = [NSMutableArray new]; then add object in this array, say->[objA addObject:@"Mohit"], and so on....Now, in Class B, just retrieve this array as(hope you can make the object of class A, say obj1), then in Class B get it like:-> NSMutableArray *objArrB = obj1.objA....That's all now you have full array of your previous class...Hope, it'll assist you and really sorry as I leave you. Gud Night...Princes.. – Mohit_Jaiswal Dec 10 '12 at 12:54

1 Answers1

0

There are two ways in which you can present a new screen.

1) with the interface builder, here you use a segue to pass something onto the new screen.

2) manually instantiating it, after it is instantiated you can just present it.

Considering you do not want to use method 1, you can use method two like this:

ScreenBClass *screenB = [self.storyboard instantiateViewControllerWithIdentifier:@"screenB"];

screenB.objectPointerInOtherClass = self.objectIWantToPass;

[self screenB animated:YES];
Pochi
  • 13,391
  • 3
  • 64
  • 104