views:

93

answers:

2

In my last question i asked how to best send a string from one view controller to another, both which were on a navigation stack: http://stackoverflow.com/questions/2898860/pass-string-from-tableviewcontroller-to-viewcontroller-in-navigation-stack

However I just realised I can either pass the path to the file in the app's document's folder as the first (the table view) has already accessed the data in the file should I pass viewcontroller the data to the pushed VC?

A: 

My first thought is that you should pass say the NSData object to the pushed view controller. If it's not too large it will save you from loading it again.

petert
A: 

Passing a reference would be less overhead than reinitializing a fresh object in the child view controller.

Set up a retain property in the child view controller for the NSString instance.

In the parent view controller, instantiate the child view controller and set its string property equal to the string you want to pass it:

childViewController.myStringProperty = parentViewControllerString;

As this increments the retain count of the string, you're not recreating the object, just keeping a reference to it.

You could instead retain an NSData instance, if you wanted. This would be less of a hit than recreating it in the child v.c.

Alex Reynolds
Absolutely, that was what I was suggesting, that you retain the object in the pushed view controller.
petert