I have a chunk of code that goes out and gets back a csv string from a rest service i coded. I split that into an array and i want to populate a uipickerview with the array but when my code gets to the count array rows part that when it bails out with EXE_BAD_ACCESS. I will past in the code below and would appreciate any insight on where to start fixing this.
header
Code:
- (void)viewDidLoad {
[super viewDidLoad];
arrayActions = [[NSMutableArray alloc] init];
ivTechAppDelegate *mainDelegate = (ivTechAppDelegate *)[[UIApplication sharedApplication] delegate];
NSURL *url = [NSURL URLWithString:@"http://mysite.com/iv_server.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"1" forKey:@"sw"];
[request setPostValue:mainDelegate.user_name forKey:@"usern"];
[request startSynchronous];
NSString *resp = [request responseString];
arrayActions = [resp componentsSeparatedByString:@","];
NSLog(@"array: %@", arrayActions);
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)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 {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [arrayActions count];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [arrayActions objectAtIndex:row];
}
- (void)dealloc {
[arrayActions release];
[super dealloc];
}
header
Code:
@interface ActionsViewController : UIViewController {
IBOutlet UIPickerView *pickerView;
NSMutableArray *arrayActions;
IBOutlet UIButton *aLoadButton;
}