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 08-23-2011, 03:37 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 17
appcody is on a distinguished road
Post NavigationController Array Advantages

Hi,

I have been reading a lot through the internet, and found out that when you use arrays and such in a navigation controller, in the long run it will save time etc. I have always been using the navigation controller and different views and linked them together like this.

Code:
#import <UIKit/UIKit.h>
#import "View1.h"
#import "View2.h"
#import "View3.h"

@interface RootViewController : UITableViewController {
	
View1 *v1;
View2 *v2;
View3 *v3;


}


@property(nonatomic,retain) View1 *v1;
@property(nonatomic,retain) View2 *v2;
@property(nonatomic,retain) View3 *v3

@end
and then in my .m file:

Code:
#import "RootViewController.h"


@implementation RootViewController


@synthesize v1;
@synthesize v2;
@synthesize v3;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];
self.title = @"Home";
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}



#pragma mark -
#pragma mark Table view data source

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
	if(indexPath.row == 0) {
 		[cell setText:@"About"];
 	}
etc.
etc.
	
    return cell;
}


...


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   
	if (indexPath.row == 0) {
		
		if(self.v1 == nil) {
			View1 *myview =
			[[About alloc] initWithNibName:@"About" bundle:[NSBundle mainBundle]];
			self.v1 = myview;
			[myview release];	
		}
		[self.navigationController pushViewController:self.v1 animated:YES];
	}	
etc.
etc.
	}	
	
}

...

@end
This just gets really tiring really fast. My question is: What are the advantages of doing it a different way? And how many different ways are there even, that would be suitable?

Thanks in advance,
appcody is offline   Reply With Quote
Old 08-23-2011, 06:19 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

This is an extremely poorly-worded question. What arrays are you talking about? You have shown 1 technique; what are you comparing it to?

And it is highly misleading to name a view controller as a view. It's a view controller; name it as a view controller. And don't abbreviate variable names like that. You aren't doing anybody, particularly yourself, any favors by doing that.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
array, controller, navigation

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: 396
15 members and 381 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, fiftysixty, gmarro, iOS.Lover, jonathandeknudt, kilobytedump, Matrix23, raymng, stanny, tymex, UMAD, xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

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