objective c - How To Use Variable Value Outside Block? -


I have the following code that is checking the connectivity of my app. I want to display a connectivity state in a UILabel which is on a custom UIView that slides while connectivity status changes.

  __ block NSString * strConnectivityStatus = @ ""; [[AFN Network Reachability Manager Shared Manager]] StartMoning]]; [END EDIT] <[AFAN Network Resolve Manager Shared Manager] SET Reability Statistics Changebox: ^ (AFNET Network Realty Status Status) {NSLog (@ "RACHAABILITY:% @", EffortsFormat Network Rebirth Stats (Status) )); StrConnectivityStatus = AFStringFromNetworkReachabilityStatus (status); SWITCH (STATUS) {Case AAENET Network Reachability Status Revanable VVN: View Connectivity Status Echiden = Falls; LblConnectivityStatus.text = AFStringFromNetworkReachabilityStatus (status); Case AAFNET NetworkSecurityStoreSubscribeWee: View ConnectivityStatus Hidden = false; LblConnectivityStatus.text = AFStringFromNetworkReachabilityStatus (status); break; Case AAFNET Network Reability Status Not Rebalable: View Connectivity: Tatas Hidden = false; LblConnectivityStatus.text = AFStringFromNetworkReachabilityStatus (status); Default: viewConnectivityStatus.hidden = false; LblConnectivityStatus.text = AFStringFromNetworkReachabilityStatus (status); break; }}];  

And then I call my custom UIV, which slides into position:

  OLSlidingMessageVC * msgConnectivityVC = [[OLSlidingMessageVC alloc] initWithTitleAndPosition: @ "Status" message: StrConnectivityStatus msgHight: & amp; ViewHead message message: & amp; View Width msgXPos: & amp; View Expeduce Message: & amp; See YPOS];  

But strConnectivityStatus is always empty because I can not access its value outside the block.

How do I reveal the status on UILabel on my UIView?

The block is not called synchronous, so the strConnectivityStatus is not set Anywhere out of the block

Just create a strConnectivityStatus with a local variable inside the block and take any action inside the block.


Comments

Popular posts from this blog

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

c# - Process.Kill() returns access denied -

c# - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments -