Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lJoct03

macrumors member
Original poster
Nov 18, 2009
31
0
help please!

THANKS!
 

Attachments

  • Screen Shot 2011-10-18 at 8.47.50 PM.png
    Screen Shot 2011-10-18 at 8.47.50 PM.png
    22.7 KB · Views: 1,201
SIGABRT means you've tried to access an invalid pointer somewhere in your program. This is one of the hardest things to diagnose through a forum because the scope of the error is so large.

Start by switching to the LLDB debugger. In my experience, the LLDB debugger is more likely to stop at the line where the invalid access happens than GDB will.

To change to the LLDB debugger (assuming your using XCode 4.x).

1. Click the left-hand side of scheme popup menu in the toolbar.
2. Edit Scheme...
3. Under the Info tab, changed debugger from GDB to LLDB.

Rerun the program. Where does it now stop?
 
Test early, test often. The smaller your changeset the easier time you will have hunting down this kind of issue.
 
this is what i get now:
 

Attachments

  • Screen Shot 2011-10-19 at 5.45.57 PM.png
    Screen Shot 2011-10-19 at 5.45.57 PM.png
    23.3 KB · Views: 6,630
  • Screen Shot 2011-10-19 at 5.45.45 PM.png
    Screen Shot 2011-10-19 at 5.45.45 PM.png
    30.8 KB · Views: 502
Do you see the dashed line between the two stack frames? This dashed line represents hidden stack frames.

You'll see a slider at the bottom of the thread view pane. Slide it to the left (I think) until you see the full stack trace; that is, until you don't see a dashed line between two stack frames.
 
ok i did it.
here it is:

what now?

PS: thanks for the help!!!
 

Attachments

  • Screen Shot 2011-10-19 at 8.29.05 PM.png
    Screen Shot 2011-10-19 at 8.29.05 PM.png
    27.7 KB · Views: 6,604
I don't know. The stack trace doesn't give me any clues. It is weird though that before the bottom of the stack trace was std::terminate and now it's not. Are you using any C++ code in your project?

I would perhaps put a breakpoint in your app delegate's application:didFinishLaunchingWithOptions: and see if it hits it. If it does hit it, step through and see what happens.
 
okay thanks!
i'll try that right now.
this is going to sound stupid, but how to i create a breakpoint?
do i just press the button next to the line?
 
HERE IS THE CODE

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [window addSubview:rootController.view];
    [self.window addSubview:[navigationController view]];
    [self.window makeKeyAndVisible];
    return YES;
    
    // Add the tab bar controller's current view as a subview of the window
    self.window.rootViewController = self.tabBarController;
    return YES;
    
}

What do i fill in for the condition, ignore, and action?
 

Attachments

  • Screen Shot 2011-10-19 at 9.34.03 PM.png
    Screen Shot 2011-10-19 at 9.34.03 PM.png
    19.2 KB · Views: 190
What do i fill in for the condition, ignore, and action?
 

Attachments

  • Screen Shot 2011-10-19 at 9.34.03 PM.png
    Screen Shot 2011-10-19 at 9.34.03 PM.png
    19.2 KB · Views: 230
Code:
    // Override point for customization after application launch.
    [window addSubview:rootController.view];
    [self.window addSubview:[navigationController view]];
    [self.window makeKeyAndVisible];
    return YES;
    
    // Add the tab bar controller's current view as a subview of the window
    self.window.rootViewController = self.tabBarController;


Errrr, sorry my man, but your code is utterly random.
You add a rootController.view, then you add a navigation, and after you return "yes", you try to add a tabbar too to the mainwindow. Which never works after a return anyway.
So seriously, have u thought about your flow, or even remotely looked up what are the standard flows in the iOS Environment? Pick one, and build on that, i think that will help you better.
 
This is my code now:

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    UIViewController *rootController = [[RootViewController alloc] init];
    navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
    [rootController release];
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [window addSubview:navigationController.view];
    
    // Add the tab bar controller's current view as a subview of the window
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
    
    
}

Still get the same error.
What should i do now?
Any help?
 
Dude. A sigabrt is the system helping you. There is a bug in your code. The system has recognized this immediately. It throws an exception that results in the SIGABRT. When this happens you need to look at the text in the debugger console. That is where the elves inside the system tell you what bug they found.

Look for the text that starts "Terminating app..." Post it here. Also the breakpoint on the exception throw will show you exactly which line of code in your app has made the boo boo.
 
This is my code now:

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    UIViewController *rootController = [[RootViewController alloc] init];
    navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
    [rootController release];
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [window addSubview:navigationController.view];
    
    // Add the tab bar controller's current view as a subview of the window
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
    
    
}

Still get the same error.
What should i do now?
Any help?

Have you listened to what i say? i actually told you what to do, but you're a bit stubborn on picking up a book huh? These are basic principles of iOS Development, even if you can get this sketchy working, you will have major memory issues etc etc.
 
Dude. A sigabrt is the system helping you. There is a bug in your code. The system has recognized this immediately. It throws an exception that results in the SIGABRT. When this happens you need to look at the text in the debugger console. That is where the elves inside the system tell you what bug they found.

Look for the text that starts "Terminating app..." Post it here. Also the breakpoint on the exception throw will show you exactly which line of code in your app has made the boo boo.


Where do i find the text that says "Terminating app..."?
 
Where do i find the text that says "Terminating app..."?
Here:
Dude. A sigabrt is the system helping you. There is a bug in your code. The system has recognized this immediately. It throws an exception that results in the SIGABRT. When this happens you need to look at the text in the debugger console. That is where the elves inside the system tell you what bug they found.

Look for the text that starts "Terminating app..." Post it here. Also the breakpoint on the exception throw will show you exactly which line of code in your app has made the boo boo.
 
This is what i got:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x72b0'
*** First throw call stack:
(0x3708c8bf 0x35e6b1e5 0x3708facb 0x3708e945 0x36fe9680 0x2fe5 0x303400c7 0x303415b3 0x3033fa73 0x3033f8a9 0x3033f71b 0x3033e667 0x2e57 0x304d335d 0x30563603 0x30564bb9 0x3049da45 0x30327227 0x30321313 0x302ef921 0x302ef3bf 0x302eed2d 0x35ba0e13 0x37060553 0x370604f5 0x3705f343 0x36fe24dd 0x36fe23a5 0x30320457 0x3031d743 0x22dd 0x229c)
terminate called throwing an exception(gdb)
 
I have no idea!
Any help?
Thanks!!!

I'm really sorry but, and I quote
reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance

It says: reason, you're trying to call objectForKey (which is used on Dictionary's and such) on an String.
Tadaaaa, rocket science up in this thread!
And that no offense to you, but, Dejo is trying his hardest best to be nice to everyone on this forum with such questions. but the answer is like right there..
 
The unrecognized selector error is a runtime exception. It means that some code tried to call a method on an object and that object doesn't implement that method. In this case the app tried to call objectForKey on a NSString object. objectForKey is an NSDictionary method, not found in NSString.

This generally happens one of two ways. 1) you do have explicit code that mistakenly calls objectForKey on a string object. You might put strings into an array and then later iterate over them and treat them as dictionaries, or something like that. Does your code have any calls to objectForKey?

2) Improper memory management can result in an object being replaced in memory with another object. If your code doesn't retain an ivar correctly then the memory used by that ivar can be replaced with another object of another type. Later when you attempt to use the ivar this new object tells you that it doesn't respond to the selector and the little man gives you the SIGABRT. This happens frequently with new coders as they don't understand memory management very well.

If you've set the exception breakpoint mentioned above this should help you to track down the line of code that is causing the problem so you can figure it out.
 
2) Improper memory management can result in an object being replaced in memory with another object. If your code doesn't retain an ivar correctly then the memory used by that ivar can be replaced with another object of another type. Later when you attempt to use the ivar this new object tells you that it doesn't respond to the selector and the little man gives you the SIGABRT. This happens frequently with new coders as they don't understand memory management very well.

A typical debugging tool for finding such errors is to run under Instruments with zombies enabled.
One way to learn how to do that is to google: ios instruments zombies.
 
The unrecognized selector error is a runtime exception. It means that some code tried to call a method on an object and that object doesn't implement that method. In this case the app tried to call objectForKey on a NSString object. objectForKey is an NSDictionary method, not found in NSString.

This generally happens one of two ways. 1) you do have explicit code that mistakenly calls objectForKey on a string object. You might put strings into an array and then later iterate over them and treat them as dictionaries, or something like that. Does your code have any calls to objectForKey?

2) Improper memory management can result in an object being replaced in memory with another object. If your code doesn't retain an ivar correctly then the memory used by that ivar can be replaced with another object of another type. Later when you attempt to use the ivar this new object tells you that it doesn't respond to the selector and the little man gives you the SIGABRT. This happens frequently with new coders as they don't understand memory management very well.

If you've set the exception breakpoint mentioned above this should help you to track down the line of code that is causing the problem so you can figure it out.

My code calls objectForKey 4 times:
(all in RootViewController.m)

Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (searching)
        return [copyListOfItems count];
    else {
    
    //Number of rows it should expect should be based on the section
    NSDictionary *dictionary = [listOfItems objectAtIndex:section];
    NSArray *array = [dictionary objectForKey:@"News"];
    return [array count];
    
    }
}

Code:
- (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];
    }
    
    // Set up the cell...
    if(searching) 
        cell.textLabel.text = [copyListOfItems objectAtIndex:indexPath.row];
    else {
    //First get the dictionary object
	NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
    NSArray *array = [dictionary objectForKey:@"News"];
    NSString *cellValue = [array objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    }
    return cell;
    
}

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    //Get the selected country
    
    NSString *selectedNews = nil;
    
    if(searching)
        selectedNews = [copyListOfItems objectAtIndex:indexPath.row];
    else {
        
        NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"News"];
        selectedNews = [array objectAtIndex:indexPath.row];
    }
    
    //Initialize the detail view controller and display it.
    DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
    dvController.selectedNews = selectedNews;
    [self.navigationController pushViewController:dvController animated:YES];
    [dvController release];
    dvController = nil;
}


Code:
- (void) searchTableView {
    
    NSString *searchText = searchBar.text;
    NSMutableArray *searchArray = [[NSMutableArray alloc] init];
    
    for (NSDictionary *dictionary in listOfItems)
    {
        NSArray *array = [dictionary objectForKey:@"News"];
        [searchArray addObjectsFromArray:array];
    }
    
    for (NSString *sTemp in searchArray)
    {
        NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
        
        if (titleResultsRange.length > 0)
            [copyListOfItems addObject:sTemp];
    }
    
    [searchArray release];
    searchArray = nil;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.