TheFrontier
TheFrontier

Reputation: 11

Expected identifier '(' in Xcode

I'm having a problem with this the first line of code, it says that there is an "expected identifier '('" Not sure if it has something to do with UIApplication. I've already declared UIApplication as a class. Someone please help me with this

    @interface UIResponder : NSObject

    @end


    Class UIApplication; UIResponder




    // Error in the line below
    - (void)applicationDidBecomeActive:(UIApplication *) application  {

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://foobar.com/news.plist"]];
request.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
request.timeoutInterval = 5.0;

[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:
 ^(NSURLResponse *response, NSData *data, NSError *error)
 {
     if (data)
     {
         NSPropertyListFormat format;

         self.dictionary = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:nil];

         // Todo: post an NSNotification to any other view controllers telling them that we have the new data.

     }
     else
     {
         // Tell user connection failed
     }
 }];

}

Upvotes: 1

Views: 882

Answers (1)

Hussain Shabbir
Hussain Shabbir

Reputation: 15015

You need to put "}]" at the end like this.

[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:
 ^(NSURLResponse *response, NSData *data, NSError *error)
 {
     if (data)
     {
         NSPropertyListFormat format;

         self.dictionary = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&format error:nil];

         // Todo: post an NSNotification to any other view controllers telling them that we have the new data.

     }
}];

Upvotes: 1

Related Questions