How can I specify the return types in GCD blocks

How can i specify the return types in GCD blocks? Here I want to return my result as NSData ...

- (NSData *)returnData:(NSString *)urlString{
    dispatch_queue_t concurrentQueue = 
    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_sync(concurrentQueue, ^{   // here return type showing error

        NSString *strUrl = urlString;
        if([strUrl length] == 0)
            return nil; // from this point i want to stop the execution of the block and return nil .

        // otherwise only continue the left operations



- (NSData *)returnData:(NSString *)urlString {
    dispatch_queue_t concurrentQueue = 
    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    // Declare your local data outside the block.
    // `__block` specifies that the variable can be modified from within the block.
    __block NSData *localData = nil;

    dispatch_sync(concurrentQueue, ^{
        // Do something with `localData`...
        localData = somethingWonderful;

    // `localData` now contains your wonderful data.
    return localData;

The block's format (parameters/return type) are specified in the function's signature. In this case, dispatch_sync uses a block with no return type and no parameters. If you want further variables to work with you need to declare them outside the block, as in the code above.

Need Your Help

Can you use MATLAB Builder JA to create Java objects from MATLAB objects

java matlab matlab-deployment

I'm trying to do a proof of concept with MATLAB objects. I want to see if you can use MATLAB objects like the one below in Java code. We need the MATLAB objects to keep state. I've used MATLAB Buil...

VB.NET process plain text file

.net visual-studio

I'm trying to use VB.NET to process a very large plain text file (2 GB). It is a database and has a field delimiter of SOH and a record delimiter of STX.