taskTable not recognized as instance variable


#1

I’m trying to build iTahDoodle and am stuck on an early section in the didFinishLaunchingWithOptions method.

Here’s the header file:

#import <UIKit/UIKit.h>
NSString *docPath(void);

@interface BNRAppDelegate : UIResponder
{

UITextField *taskField;
UIButton *insertButton;
UITableView *taskTable;

NSMutableArray *tasks;

}

  • (void) addTask:(id)sender;

@property (strong, nonatomic) UIWindow *window;

@end

Here’s the implementation file for the method
#import “BNRAppDelegate.h”

NSString *docPath()
{
NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@“data.td”];
}

@implementation BNRAppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    NSArray *plist =[NSArray arrayWithContentsOfFile:docPath()];
    if(plist){
    tasks = [plist mutableCopy];
    } else {
    tasks = [[NSMutableArray alloc] init];
    }
    CGRect tableFrame = CGRectMake(0,80,320,380);
    CGRect fieldFrame = CGRectMake(20,40,200,31);
    CGRect buttonFrame = CGRectMake(228,40,72,31);

    taskTable = [[[UITableView alloc] initWithFrame:tableFrame
    style:UITableViewStylePlain];
    // an error here – red print – “expected identifier” — and taskTable appears black (greeen for instance variables)

    [taskTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];

    taskField = [[UITextField alloc] initWithFrame:fieldFrame];
    [taskField setBorderStyle:UITextBorderStyleRoundedRect];

    [taskField setPlaceholder:@“Type a task, tap Insert”];

    // create and configure a rounded rect Insert Button
    insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [insertButton setFrame:buttonFrame];
    [insertButton addTarget:self
    action:@selector(addTask:)
    forControlEvents:UIControlEventTouchUpInside];
    [insertButton setTitle:@"Insert"
    forState:UIControlStateNormal];
    [[self window] addSubview:taskTable];
    [[self window] addSubview:taskField];
    [[self window] addSubview:insertButton];

               [[self window] setBackgroundColor:[UIColor whiteColor]];
               [[self window] makeKeyAndVisible];
               return YES;
    

}

  • (void)applicationWillResignActive:(UIApplication *)application
    {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or…

Suggestions?