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 09-17-2010, 06:01 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 18
initWithName is on a distinguished road
Default how to modify an array inside a child view

I know how to copy array values into a child view, but how do you modify an array from within the child view?
initWithName is offline   Reply With Quote
Old 09-17-2010, 07:20 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 249
gabacus is on a distinguished road
Default

hmmm... ok, im no expert but i will give this a go...

by "child view" i assume you are talking about inheritance... so you have a super view and a sub view (or child view)

if this is the case, then your child view inherits all the methods of the super view, so if you have a method in your super view that modifies the array, then you can call that method directly from the child view

i think thats how it goes anyway...
__________________
-- Website --
SpartanApps

-- Current Apps --
Musicopoulos
gabacus is offline   Reply With Quote
Old 09-17-2010, 08:50 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 18
initWithName is on a distinguished road
Default

I don't have any custom methods that modify the array. I'm going to use NSMutableArray methods to add, delete, and change items.

By child view I'm talking about views that are made like this:
Code:
[self.navigationController pushViewController:detailViewController animated:YES];
After that code gets executed the view switches to the child view.
initWithName is offline   Reply With Quote
Old 09-17-2010, 11:29 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

ok well then thats your problem. The array does not belong to the view, but the VIEW CONTROLLER. so you could access it like this:

Code:
NSArray *newArray = [NSArray array];
self.navigationController.visibleViewController.myArray = newArray;
kapps11 is offline   Reply With Quote
Old 09-17-2010, 06:20 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 18
initWithName is on a distinguished road
Default

[quote]
Quote:
Originally Posted by kapps11 View Post
ok well then thats your problem. The array does not belong to the view, but the VIEW CONTROLLER. so you could access it like this:

Code:
NSArray *newArray = [NSArray array];
self.navigationController.visibleViewController.myArray = newArray;
That doesn't work. Say I created an NSMutableArray, then the code I posted above gets executed. So control transfers to another view controller. Inside that view controller I have this code:

Code:
NSLog(@"Number of students in array is %i", self.navigationController.visibleViewController.myArray.count);
It says
Quote:
error: request for member 'myArray' in something not a structure or union
I don't want to access the visibleViewController I want to access the view controller that was showing before the view switched.
initWithName is offline   Reply With Quote
Old 09-17-2010, 07:42 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

ok well in that case things get more complicated. UINavigationController has an array property called viewControllers that has all of the viewcontrollers in it. The hard part is knowing which one is yours. You could do some sort of check like an if statement because NSObject has some functions that tell you what kind of class you are dealing with *(i cant think of them off hand) but u culd use that and an if statement and just cycle through them to find the one you're looking for and then access it that way
kapps11 is offline   Reply With Quote
Reply

Bookmarks

Tags
array, view

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: 308
16 members and 292 guests
2ndSegment, cayladv57, cgokey, dermotos, djohnson, Domele, Hamad, heshiming, linkmx, markuschow, pungs, Rudy, Sloshmonster, teebee74, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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