- (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;
}
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?
// 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;
- (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;
}
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.
Here:Where do i find the text that says "Terminating app..."?
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.
*** 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!!!
reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance
I guess now would be as good a time as any to learn some debugging skills.I have no idea!
Any help?
Thanks!!!
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.
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.
- (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];
}
}
- (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;
}
- (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;
}
- (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;
}