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 01-10-2010, 10:58 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default If statement causes a 'SIGABRT' signal to be received

Hi Everyone,

In my program, I have a table. When the user selects a certain cell, I want it to take them to one of two different views, depending on which they pressed.

I am using an IF/ELSE statement to achieve this, however, I think there may be a problem with my code, because the program freezes up both on my Iphone, and in the simulator, and Xcode displays a message saying:

GDB: Program received signal: "SIGABRT"

So here is the IF statement, please have a look over it, and tell me what I am doing wrong, or give me some tips:

Code:
if (selectedItem =  glossary) {
		DisclosureViewController *dsController = [[DisclosureViewController alloc] initWithNibName:@"DisclosureView" bundle:[NSBundle mainBundle]];
 		[self.navigationController pushViewController:dsController animated:YES];
		[dsController release];
		dsController = nil;
		
	}
	else {
		DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
		dvController.selectedItem = selectedItem;
		[self.navigationController pushViewController:dvController animated:YES];
		[dvController release];
		dvController = nil;
	}
Thanks in advance,

Aaron
Sentis is offline   Reply With Quote
Old 01-10-2010, 11:07 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 519
Default

did you mean to do == instead of =?
__________________
Water Your Body (ON SALE $0.99)

Top Paid in Health & Fitness!

Tic Tac Pro ($0.99)

New and Noteworthy!

Click here to see a really cool website
bravetarget is offline   Reply With Quote
Old 01-10-2010, 11:13 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default

I added that in, and it still displays the SIGABRT error when I select the cell for the different view.

Thanks

Last edited by Sentis; 01-10-2010 at 11:27 PM.
Sentis is offline   Reply With Quote
Old 01-10-2010, 11:34 PM   #4 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default

This might help.
These are the couple lines of code relating to the problem.

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
		NSString *selectedItem =[listOfItems objectAtIndex:indexPath.row];
		NSString *glossary = @"Water";
thanks!
Sentis is offline   Reply With Quote
Old 01-10-2010, 11:52 PM   #5 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 519
Default

where do you allocate listofitems array?
__________________
Water Your Body (ON SALE $0.99)

Top Paid in Health & Fitness!

Tic Tac Pro ($0.99)

New and Noteworthy!

Click here to see a really cool website
bravetarget is offline   Reply With Quote
Old 01-11-2010, 12:00 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default

In the ViewdidLoad method:

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	
	
	listOfItems = [[NSMutableArray alloc] init];
	
	
	[listOfItems addObject:@"Periodic Table"];
Sentis is offline   Reply With Quote
Old 01-11-2010, 12:18 AM   #7 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 580
Default

It's getting late, so I could be missing something, but I don't see any obvious issues with anything you've posted. You'll probably get better help if you post the entire class (or, if that's too big, at the very least the complete code to the didSelectRowAtIndexPath: method). It's very hard to debug when there's only a few brief excerpts of code scattered across multiple posts.
ChrisL is offline   Reply With Quote
Old 01-11-2010, 12:43 AM   #8 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default

Here is the full code:

Code:
#import "RootViewController.h"
#import "TableViewAppDelegate.h"
#import "DetailViewController.h"
#import "DisclosureViewController.h"

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	
	
	listOfItems = [[NSMutableArray alloc] init];
	
	
	[listOfItems addObject:@"Periodic Table"];
	[listOfItems addObject:@"Acids & Bases"];
	[listOfItems addObject:@"Metals"];
	[listOfItems addObject:@"Water"];

self.navigationItem.title = @"Blah";

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; }


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return[listOfItems count];
}



- (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];
		//cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
	}	

    
  	
	NSString *cellValue =[listOfItems objectAtIndex:indexPath.row];
	cell.textLabel.text = cellValue;


    return cell;
	}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
		NSString *selectedItem =[listOfItems objectAtIndex:indexPath.row];
		NSString *glossary = @"Water";
	
	if (selectedItem ==  glossary) {
		DisclosureViewController *dsController = [[DisclosureViewController alloc] initWithNibName:@"DisclosureView" bundle:[NSBundle mainBundle]];
 		[self.navigationController pushViewController:dsController animated:YES];
		[dsController release];
		dsController = nil;
		
	}
	else {
		DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
		dvController.selectedItem = selectedItem;
		[self.navigationController pushViewController:dvController animated:YES];
		[dvController release];
		dvController = nil;
	}

	
}
	


- (void)dealloc {
	
	[listOfItems release];
	[selectedItem release];
	[glossary release];
    [super dealloc];
}


@end
There are also a couple of warnings about local declarations of 'selectedItem' and 'glossary' hiding the instance variable ould that have anything to do with it?

thanks again!

Last edited by Sentis; 01-11-2010 at 12:49 AM.
Sentis is offline   Reply With Quote
Old 01-11-2010, 01:22 AM   #9 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 9
Default

I found the problem.

The If statement is fine! the problem occurs sometime during the loading of the 'Disclosure View'. But i have it worked out.

Thanks again for all of your help!
Sentis is offline   Reply With Quote
Old 01-11-2010, 01:26 AM   #10 (permalink)
Registered Member
 
pereorra's Avatar
 
Join Date: Oct 2009
Location: Mataró, Barcelona, Spain
Posts: 14
Default

I think the problem is in

Code:
if (selectedItem ==  glossary)
You can't compare strings with ==

Try

Code:
if ([selectedItem isEqualToString: glossary])
__________________
My Apps:



My Website: www.pereorra.com
pereorra is offline   Reply With Quote
Reply

Bookmarks

Tags
error, iphone, navigation, uitableview

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: 271
20 members and 251 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, JasonR, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
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 03:10 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0