Expected Identifier


Hi i am new to Objective C programming, i hve a problem with the Code in this section.

I am using Xcode 4.6.2 and right now i stuck at BNRAppDelegate.m:

[code]#import “BNRAppDelegate.h”

// Helper function to fetch the path to our to-do data stored on disk
NSString *docPath()
NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);

return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@"data.td"];

#pragma mark - Application delegate callbacks


  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    //Attemp to load an existing to-do dtatset from an array stored to disk.
    NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
    if (plist) {
    // If there was a dataset available, copy it into our instance variable.
    tasks = [plist mutableCopy];
    } else {
    //Otherwise, just create an empty one to get us started.
    tasks = [[NSMutableArray alloc] init];

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

// Define the frame rectangles of tghe three UI elements
// CGRectMake() creates a CGRect from (x, y, wifth, height)
CGRect tableFrame = CGRectMake(0, 80, 320, 380);
CGRect fieldFrame = CGRectMake(20, 40, 200, 31);
CGRect buttonFrame = CGRectMake(228, 40, 72, 31);

// Create and configure the table view
taskTable = [[UITableView alloc] initWithFrame:tableFrame
[taskTable setSeperatorStyle:UITableViewCellSeparatorStyleNone];

// Create and configure that text field whrer new tasks will be typed
taskField = [[UITextField alloc] initWithFrame:]fieldFrame];
[taskField setBorderStyle:UITextBorderStyleRoundedRect];
[taskField setPlaceholder:@“Type a task, tap Insert”];

// Create and config rounded rect Insert button
insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[insertButton setFrame:buttonFrame];

// Buttons behave using a target/action callback
// Configure the Insert button´s action to call this object´s -addTask: method
[insertButton addTarget:self
// Give the button the title
[insertButton setTitle:@"Insert"

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


At: [code]

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Xcode tells me two errors: 1. Missing context for method declaration, 2. Expected identifier

I read in this forum about pragma mark problems are my errors related to this?

Also here is the code of BNRAppDelegate.h:

#import <UIKit/UIKit.h>

// Declare a helper function that we will use to get a path
// to the location on disk where we can save the to-do list
NSString *docPath(void);

@interface BNRAppDelegate : UIResponder 

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

- (void)addTask:(id)sender;

@property (strong, nonatomic) UIWindow *window;


Thanks for your help.


Either you have jettisoned some code when posting it, or you are really missing the closing curly brace token at the end of application:didFinishLaunchingWithOptions: method.

It should look like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Syntax: The body of a method or function must always be enclosed between matching curly braces:

void Foo ()


Thanks, you´re right that solves the problem.