Question: My problem is quite simple   

Suppose I have those class:

```
public class A
{
    public Collection<B> B { get; set; }
    public Collection<C> C { get; set; }
}

public class B
{
    public int IntB { get; set; }
}

public class C
{
    public string StringC { get; set; }
}

```

And I write a function:

```
public void GetValue(string fieldName){
        A a = new A();
        PropertyInfo infor = typeof(A).GetProperty(fieldName);
        object obj = infor.GetValue(a,null);
}

```

My question is how can I turn obj to corresponding Collection, in this case is `Collection<B>` or `Collection<C>`, depending in fieldName value   

Thank in advance

Answer: 
You should use Apple's Reachability class

<http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html>

after implementation you can use this in the delegate:

```
- (void) configureTextField:  (Reachability*) curReach
{
    NetworkStatus netStatus = [curReach currentReachabilityStatus];
    BOOL connectionRequired= [curReach connectionRequired];
    NSString* statusString= @"non";
    switch (netStatus)
    {
        case NotReachable:
        {
            statusString = @"Access Not Available";

            //Minor interface detail- connectionRequired may return yes, even when the host is unreachable.  We cover that up here...
            connectionRequired= NO;  
            break;
        }

        case ReachableViaWWAN:
        {
            statusString = @"Reachable WWAN";

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cellular Data Detected" message:@"You are using Cellular data such as 3G or Edge. Downloading large amount of data may effect your cellular internet package costs. To avoid such extra cost kindly use Wifi." 
                                                           delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];

            break;
        }
        case ReachableViaWiFi:
        {
            statusString= @"Reachable WiFi";

            break;
        }
    }
    if(connectionRequired)
    {
        statusString= [NSString stringWithFormat: @"%@, Connection Required", statusString];
    }
    NSLog(@"Network= %@",statusString);
    if ([statusString isEqualToString:@"Access Not Available"]){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"It seems you are not connected to the internet, the app will try to load from the last cached data - assuming this data exist." 
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    //textField.text= statusString;
}

- (void) updateInterfaceWithReachability: (Reachability*) curReach
{
    if(curReach == hostReach)
    {
        //[self configureTextField: remoteHostStatusField imageView: remoteHostIcon reachability: curReach];
       // NetworkStatus netStatus = [curReach currentReachabilityStatus];
       // BOOL connectionRequired= [curReach connectionRequired];

        [self configureTextField:curReach];

    }   
}

```
Yes, Apple has an example project that shows that. [Reachability](http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html)

And [here's](http://www.raddonline.com/blogs/geek-journal/iphone-sdk-testing-network-reachability/) an example.