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-07-2010, 11:52 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 37
Smokin Joe is on a distinguished road
Default accessing previous allocated viewController and its methods

In my app, a specific ViewController overlays itself (as navigational buttons) over a galleryViewController that can be switched around.

However, my issue is that after I allocate a new galleryViewController, then switch to that view, I want to be able to send back information regarding what is being displayed to the original ViewController.

So within this galleryViewController I alloc a viewController object and attempt to do what needs to be done.

However, I've come to understand that this viewController object is a NEW allocated object. So the various UIButtons I want to make hidden and unhide are NOT the ones currently present in the superview - they haven't even been allocated.

How can I access the original viewController - it's the one that is declared and addedToTheSubview in the appDelegate.

I am not really sure how much I was able to properly relate, if there are any specific code questions please ask and I can post it. I don't have any errors in my code, just more of a question of syntax.

Thanks in advance!
Smokin Joe is offline   Reply With Quote
Old 07-07-2010, 12:23 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 37
Smokin Joe is on a distinguished road
Default

In case it helps:

Essentially I have a parentViewController that allocates and brings into the superview a childViewController. On this childViewController I have a performTransition method that needs to trigger a method within the parentViewController.

I've tried to do:

Code:
[parentViewController doTheThing:index]
However the parentViewController needs to be allocated, and when I allocate it, the object is different than the actual Parent parentViewController - so everything I'd want to manipulate hasn't been initialized yet (or even added to the view for that matter).

How can I access the already existing parentViewController?
Smokin Joe is offline   Reply With Quote
Old 07-07-2010, 01:04 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 37
Smokin Joe is on a distinguished road
Default

So I've learned I need to access it through the appDelegate so I have these lines of code in my childViewController:

Code:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
ParentViewController *pvc = appDelegate.viewController;
[pvc doTheThing:index];
[pvc release];
However, some odd behavior takes place. If I remove the [pvc release], I can go through all my gallery slides, my UIButtons are manipulated exactly as I would want... but I just feel that [pvc release] is supposed to be there.

But with it I can only go through the above code twice before it crashes with an EXC_BAD_ACCESS. I think it probably has something to do with my rudimentary knowledge of the iOS syntax, but anyone willing to explain to me would be greatly thanked!

So to anyone following along, all I had to do was remove [pvc release]; from my above code and everything works superfantastic.. Even though, I feel that may lead to a memory issue.

But hey, I've been wrong before.

Last edited by Smokin Joe; 07-07-2010 at 03:42 PM.
Smokin Joe 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: 329
9 members and 320 guests
bignoggins, Chickenrig, firecall, givensur, iNet, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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