1

This is a total noob question but I'm testing out AFNetworking2 specifically, the UIWebView+AFNetworking piece. But how do I call loadRequest. I have:

    NSURL *websiteUrl = [NSURL URLWithString:@"http://www.google.com"];  //fine
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:websiteUrl];  //find


   [self.myWebView loadRequest:urlRequest progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))^{ // do I need second carat?
        //NSLog(@"writing bytes %i", bytesWritten);  // how to get access to bytesWritten?
        NSLog(@"writing bytes");

    }....

but I want to NSLog the bytesWritten. Block syntax always throws me for a loop. Do I need the second carat in the call?

Here's a link to docs for the call: http://cocoadocs.org/docsets/AFNetworking/2.0.3/Categories/UIWebView+AFNetworking.html

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
timpone
  • 19,235
  • 36
  • 121
  • 211

2 Answers2

2

This is the proper syntax

[self.myWebView loadRequest:urlRequest progress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite)){ 
    NSLog(@"writing bytes %lu", (unsigned long)bytesWritten);
}];

References:

Community
  • 1
  • 1
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
1

A "second carat" would be approx. 400 milligrams. The word you are looking for is "caret".


This is how you pass in a literal block:

[Foo doStuff:^(T1 arg1, T2 arg2) {
    // and this is how you use the arguments:
    NSLog(@"Arg 2: %@", arg2);
}];