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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 04-06-2009, 07:13 PM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 3
Default Next and Previous episodes in NSArray question

In my app, users are able to drill down from a series of episodes to an individual episode. In the individual episode the users are supposed to be able to go to the next and previous episodes using buttons.

As it stands right now, when user is in the ViewSeries screen and clicks an epiosode, the accessoryButtonTapped method assigns the indexPath of the selected episode to the ViewEpisode screen like this:

Code:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
		
ViewEpisodeController *viewEpisodeController = [[ViewEpisodeController alloc] initWithNibName:@"ViewEpisode" bundle:nil];

		viewEpisodeController.episode = ((Episode *)[[episodeSet episodes] objectAtIndex:indexPath.row]);

		viewEpisodeController.parentEpisodeSet = episodeSet;

	        viewEpisodeController.episodeIndexPath = indexPath;
		
		[self.navigationController pushViewController:viewEpisodeController animated:YES];
		
		[viewEpisodeController release];
	}
}

so I can perform operations like this in the ViewEpisode screen:

Code:
-(IBAction)switchToPreviousEpisode:(id)sender {

		ViewEpisodeInnerTableViewController *temp_inner_table = [[ViewEpisodeInnerTableViewController alloc] init];

		Episode *previousEpisode = [[parentEpisodeSet episodes] objectAtIndex:episodeIndexPath.row -1];
		
		self.episodeIndexPath = [[parentEpisodeSet episodes] objectAtIndex:episodeIndexPath.row -1];
		
		temp_inner_table.episode = previousEpisode;
		self.previousViewEpisodeInnerTableViewController = temp_inner_table;
		[temp_inner_table release];
}
My question: Is this the best way to navigate from an object in an array to the next and previous objects? Is there a better way to do this whole thing? I am quite new, so thanks for your patience!
mvague11 is offline   Reply With Quote
Reply

Bookmarks

Tags
nsarray, nsmutablearray, tableview

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: 250
23 members and 227 guests
ADY, bookesp, chillyh, ckgni, dacapo, Dani77, Davey555, Desert Diva, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, prchn4christ, Raggou, Rudy, ryantcb, themathminister, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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