Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-11-2010, 04:03 PM   #1 (permalink)
Registered Member
 
K2mia's Avatar
 
Join Date: Jun 2010
Posts: 29
K2mia is on a distinguished road
Default Basic Question: Copying an array from one viewcontroller to another ?

Hi, I'm sure this is basic and I am missing the obvious.

I have an app that has two view controllers, the delegate is used to switch between the two controllers. Lets call these ViewController1 and ViewController2.

If I have an NSMutableArray *arr defined and loaded with data in ViewController1 what is the best way to use this data in ViewController2?

I have tried the following in ViewController2's viewDidLoad method but this doesn't work:

Code:
TMCClientAppDelegate *mainDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
arr = [mainDelegate.viewController1.arr copy];
In MyAppDelegate I have the property viewController1 created as the instance of ViewController1, and arr is a property of ViewController1, so am not sure why I cannot access it this way.

Anyone see whats wrong here or can suggest a better way to do this?

Thanks!
Andy
K2mia is offline   Reply With Quote
Old 07-11-2010, 04:09 PM   #2 (permalink)
Registered Member
 
K2mia's Avatar
 
Join Date: Jun 2010
Posts: 29
K2mia is on a distinguished road
Default

I found the answer, I was referencing the wrong ViewController class and accessing the wrong data. One question remains though, is there a better way to accomplish this?

Thanks,
Andy
K2mia is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 338
16 members and 322 guests
akphyo, alexP, appservice, cgokey, EXOPTENDAELAX, flamingliquid, guusleijsten, mariano_donati, ohmniac, Paul Slocum, PavelSea, SLIC, Sloshmonster, Sonuye857, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:37 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0