title: __block variable returns null. How can I access the NSString inside the __block variable?
body: <p>I am using this findAllMessages() function to return a NSString with information about each message. 
  Everything goes well until I go outside of the block and the concatenatedMessage string is null. </p>
  
  <p>The last three lines concatenatedMessage return null:</p>
  
  <pre><code> NSLog(@"%@",concatenatedMessage);
   NSString *newString = concatenatedMessage;
   return newString;
  </code></pre>
  
  <p>How can I access the value of concatenatedMessage outside of the block so that concatenatedMessage is not null? </p>
  
  <pre><code>+(NSString *) findAllMessages{
  
      __block NSMutableArray *totalMessages = [[NSMutableArray alloc] init];
      __block NSDictionary *values;
      __block NSString *concatenatedMessage;
  
      FIRUser *current_user = [[FIRAuth auth] currentUser];
      FIRDatabaseReference *dbReference = [[[[FIRDatabase database] reference] child:@"Messages"] child:current_user.uid];
      FIRDatabaseQuery *allMessages = [dbReference queryOrderedByChild:current_user.uid];
  
      [allMessages observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
          NSMutableDictionary *eachMessage = snapshot.value;
          concatenatedMessage = @"";
          for(id key in eachMessage){
              [totalMessages addObject:key];
              values = [eachMessage objectForKey:key];
              for(id key2 in values){
                  concatenatedMessage = [concatenatedMessage stringByAppendingString:[values objectForKey:key2]];
                  concatenatedMessage = [concatenatedMessage stringByAppendingString:@"^^"];
              }
              concatenatedMessage = [concatenatedMessage stringByAppendingString:@"%%"];
          }
      }];
  
      NSLog(@"%@",concatenatedMessage);
      NSString *newString = concatenatedMessage;
      return newString;
  }
  </code></pre>
  
  <p>THANKS!!</p>