App simulator insert part help!


#1

Hello guys!! first of all thank you for doing this, a lot of help from people is what i really need right now!
i’m in page 246 and for some reason I run my app, simulator is good… everything going okay and then I go to the text bar “Type a task, tap Insert”, then i go click insert and it takes me back to Xcode to this part…
#import <UIKit/UIKit.h>

#import “BNRAppDelegate.h”

int main(int argc, char * argv[])
{

@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([BNRAppDelegate class])); :cry:  :cry:  :cry:  I don't get why is like crashing
    
    
}

}

Here is my code
//
// BNRAppDelegate.h
// iTahDoodle
//
// Created by Pablo G on 3/25/14.
// Copyright © 2014 Big Nerd Ranch. All rights reserved.
//

//We will add four properties and an instance method:

#import <UIKit/UIKit.h>

@interface BNRAppDelegate : UIResponder <UIApplicationDelegate, UITableViewDataSource>

@property (strong, nonatomic) UIWindow *window;

@property (nonatomic)UITableView *taskTable;
@property(nonatomic)UITextField *taskField;
@property(nonatomic) UIButton *insertButton;

@property (nonatomic)NSMutableArray *tasks;

-(void)addTask:(id)sender;

@end

//
// BNRAppDelegate.m
// iTahDoodle
//
// Created by Pablo G on 3/25/14.
// Copyright © 2014 Big Nerd Ranch. All rights reserved.
//

#import “BNRAppDelegate.h”
@implementation BNRAppDelegate
#pragma mark - Application delegate callbacks

#pragma mark - Actions

#pragma mark - Table view management

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//Because this table view only has one section,
//the number of rows in it is equal to the number
//of items in the tasks array
return[self.tasks count];
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
//To improve performance, this method first checks
// for an existing cell object that we can reuse
//If there isn’t one, then a new cell is created
UITableViewCell *c = [self.taskTable dequeueReusableHeaderFooterViewWithIdentifier:@“Cell”];

//Then we(re) configure the cell based on the model object,
//In this case the tasks array,...
NSString *item = [self.tasks objectAtIndex:indexPath.row];
c.textLabel.text = item;

//... and hand the properly configured cell back to the table view
return c;

}

-(void) addTask:(id)sender
{
//Get the task
NSString *text = [self.taskField text];

//Quit here is taskField is empty
if([text length] == 0) {
    return;
}

//Log text to console
//NSLog(@"Task entered: %@", text);

//Add it to the working array
[self.tasks addObject:text];

//Refresh the table so that the new item shows up
[self.taskTable reloadData];

//Clear out the text field
[self.taskField setText:@""];

//Dismiss the keyboard
[self.taskField resignFirstResponder];

}

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Create an empty array to get us started
self.tasks = [NSMutableArray array];

//Create and configure the UIWindow instance
//A CGRect is a struct with an origin(x,y) and a size (width, height)
CGRect winFrame = [[UIScreen mainScreen] bounds];
UIWindow *theWindow = [[UIWindow alloc] initWithFrame];
self.window = theWindow;

//Define the frame rectangles of the three UI Elements
//CGRectMake() creates a CGRect from (x,y, width, height)
CGRect tableFrame= CGRectMake(0,80,winFrame.size.width, winFrame.size.height-100);
CGRect fieldFrame= CGRectMake(20, 40, 200, 31);
CGRect buttonFrame = CGRectMake(228, 40, 72, 31);

//Create and configure the UITableView instance
self.taskTable = [[UITableView alloc] initWithFrame:tableFrame
                                                     style:UITableViewStylePlain];
self.taskTable.separatorStyle = UITableViewCellSeparatorStyleNone;

//Make the BNRAppDelegate the table view's data source
self.taskTable.dataSource = self;

//Tell the table view which class to instantiate whenever it
//needs to create a new cell
[self.taskTable registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

//Create and configure the UITextField instance where new tasks will be entered
self.taskField = [[UITextField alloc]initWithFrame:fieldFrame];
self.taskField.borderStyle=UITextBorderStyleRoundedRect;
self.taskField.placeholder = @"Type a task, tap Insert";


//Create and configure the UIButton instance
self.insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.insertButton.frame = buttonFrame;

//Give the button a title
[self.insertButton setTitle: @"Insert" forState:UIControlStateNormal];

//Set the target and action for the Insert button
[self.insertButton addTarget:self action:@selector(addTask:) forControlEvents:UIControlEventTouchUpInside];

//Add our three UI elements to the window
[self.window addSubview:self.taskTable];
[self.window addSubview:self.taskField];
[self.window addSubview:self.insertButton];

//Finalize the window and put in on the screen
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;

}

@end

thank you guys for helping this newbie in Objective C :geek: :ugeek: