New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
iOS Development Discussion on developing apps for the iOS platform.

picker crashing


Post Reply New Thread Subscribe

 
Thread Tools
sigappdevel

 
Member Since: Aug 08, 2011
Posts: 1
sigappdevel is on a distinguished road

sigappdevel is offline
I have a uipicker and i want to change what the array after switching a uisegementedcontrol. After a I switch, the list doesn't updated after I selected it, only after I turn it do the elements change and it will crashed at the bottom after it switches.

Does anybody know have to fix this. I have attached my code


//greekfinderViewController.h

#import <UIKit/UIKit.h>


@interface greekfinderViewController : UIViewController
<UIPickerViewDelegate, UIPickerViewDataSource>{
IBOutlet UIPickerView *doublePicker;
NSArray *greeklist;
NSArray *fraternityArray;
NSArray *sororityArray;
IBOutlet UISegmentedControl *fratsoro;
}

@property (nonatomic, retain) IBOutlet UISegmentedControl *fratsoro;
@property (nonatomic,retain) UIPickerView *doublePicker;
@property (nonatomic,retain) NSArray *greeklist;
@property (nonatomic,retain) NSArray *fraternityArray;
@property (nonatomic,retain) NSArray *sororityArray;

- (IBAction) setPicker: (id) sender;

@end


//greekfinderViewController.m

#import "greekfinderViewController.h"

@implementation greekfinderViewController

@synthesize doublePicker;
@synthesize fratsoro;
@synthesize greeklist;
@synthesize sororityArray;
@synthesize fraternityArray;

// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibNameNSString *)nibNameOrNil bundleNSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}



// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
[super loadView];
}


-(void) frats
{

fraternityArray = [[NSArray alloc] initWithObjects:
@"Acacia",
@"Alpha Chi Rho",
@"Alpha Delta Gamma",
@"Alpha Delta Phi",
@"Alpha Epsilon Pi",
@"Alpha Gamma Rho",
@"Alpha Gamma Sigma",
@"Alpha Kappa Lambda",
@"Alpha Phi Alpha",
@"Alpha Phi Delta",
@"Alpha Sigma Phi",
@"Alpha Tau Omega",
@"Beta Chi Theta",
@"Beta Theta Pi",
@"Chi Phi",
@"Chi Psi",
@"Delta Chi",
@"Delta Epsilon Psi",
@"Delta Kappa Epsilon",
@"Delta Lambda Phi",
@"Delta Phi",
@"Delta Psi",
@"Delta Sigma Phi",
@"Delta Tau Delta",
@"Delta Upsilon",
@"Farmhouse",
@"Iota Nu Delta",
@"Iota Phi Theta",
@"Kappa Alpha Order",
@"Kappa Alpha Psi",
@"Kappa Alpha Society",
@"Kappa Delta Phi",
@"Kappa Delta Rho",
@"Kappa Sigma",
@"Lambda Chi Alpha",
@"Lambda Phi Epsilon",
@"Lambda Sigma Upsilon",
@"Lambda Theta Phi",
@"Omega Psi Phi",
@"Phi Alpha Epsilon",
@"Phi Beta Kappa",
@"Phi Beta Sigma",
@"Phi Delta Epsilon",
@"Phi Delta Psi",
@"Phi Delta Theta",
@"Phi Gamma Delta",
@"Phi Iota Alpha",
@"Phi Kappa Psi",
@"Phi Kappa Sigma",
@"Phi Kappa Tau",
@"Phi Kappa Theta",
@"Phi Mu Delta",
@"Phi Sigma Alpha",
@"Phi Sigma Kappa",
@"Phi Sigma Phi",
@"Pi Kappa Alpha",
@"Pi Kappa Phi",
@"Pi Lambda Phi",
@"Psi Upsilon",
@"Sigma Alpha Epsilon",
@"Sigma Alpha Mu",
@"Sigma Beta Rho",
@"Sigma Chi",
@"Sigma Lambda Beta ",
@"Sigma Nu",
@"Sigma Phi Delta",
@"Sigma Phi Epsilon",
@"Sigma Phi Society",
@"Sigma Pi",
@"Sigma Tau Gamma",
@"Tau Delta Phi",
@"Tau Epsilon Phi",
@"Tau Kappa Epsilon",
@"Theta Chi",
@"Theta Delta Chi ",
@"Theta Tau",
@"Theta Xi",
@"Triangle",
@"Zeta Beta Tau-",
@"Zeta Psi",
nil];


}

- (void) sorts{
sororityArray = [[NSArray alloc] initWithObjects:
@"Alpha Chi Omega",
@"Alpha Delta Pi",
@"Alpha Gamma Delta",
@"Alpha Epsilon Phi",
@"Alpha Omicron Pi",
@"Alpha Omicron Pi",
@"Alpha Phi",
@"Alpha Sigma Alpha",
@"Alpha Sigma Tau",
@"Alpha Xi Delta",
@"Gamma Phi Beta",
@"Delta Delta Delta",
@"Delta Gamma",
@"Delta Zeta",
@"Delta PHi Epsilon",
@"Zeta Tau Alpha",
@"Theata Phi Alpha",
@"Kappa Alpha Teta",
@"Kappa Delta",
@"Kappa Kappa Gamma",
@"Pi Beta Phi",
@"Sigma Delta Tau",
@"Sigma Kappa",
@"Sigma Sigma Sigma",
@"Phi Mu",
@"Phi Sigma Sigma",
@"Chi Omega",
nil];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

[super viewDidLoad];
fratsoro.tintColor = [UIColor blueColor];
fratsoro.selectedSegmentIndex = 0;
[self frats];
self.greeklist =fraternityArray;
[fraternityArray release];


}

-(IBAction)setPicker id) sender{
switch (fratsoro.selectedSegmentIndex) {
case 0:
[self frats];
self.greeklist = fraternityArray;
break;
case 1:
[self sorts];
self.greeklist = sororityArray;
break;

}
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientationUIIn terfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[doublePicker release];
[greeklist release];
[sororityArray release];
[fraternityArray release];
[super dealloc];
}
-(NSInteger)numberOfComponentsInPickerViewUIPicke rView *)pickerView
{
return 1;
}


-(NSInteger)pickerViewUIPickerView *)pickerView
numberOfRowsInComponentNSInteger)component
{
switch (fratsoro.selectedSegmentIndex) {
case 0:
return[fraternityArray count];
break;
case 1:
return[sororityArray count];
break;
default:
return[fraternityArray count];
break;
}
}
-(NSString *)pickerViewUIPickerView *)pickerView
titleForRowNSInteger)row
forComponentNSInteger)component
{
switch (fratsoro.selectedSegmentIndex) {
case 0:
return[self.greeklist objectAtIndex:row];
break;
case 1:
return[self.greeklist objectAtIndex:row];
break;
default:
return[self.greeklist objectAtIndex:row];
break;}
}
@end
QUOTE Thanks

Post Reply New Thread Subscribe


« How to slide/navigate to another uitable view | UISplitViewController problem »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Crashing, freezing, frustrating! Cad11 OS X - Operating System 1 02-05-2011 02:47 PM
OSX 10.4.11 New fonts are crashing Firefox AND Adobe Acrobat RBCJoker OS X - Operating System 4 12-22-2010 03:22 PM
MacBook Pro Keeps Crashing....Help Please jcharman Apple Notebooks 8 07-18-2010 12:34 PM
Color picker picks wrong colors Katedu Images, Graphic Design, and Digital Photography 0 06-09-2010 11:49 PM
My browsers have been crashing all day! maconvert Switcher Hangout 0 01-08-2010 12:24 AM

All times are GMT -4. The time now is 11:20 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?