Question: I have created 5 buttons using for loop based on incrementing y axis value in `CGRectMake`. But how can i change the background color of button when i clicked each button?and also title AND having alertview for each button??pls suggest me answer..

```
//array taken for button titles
NSArray *array1=[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5", nil];

int k=0;  

for(int i=50;i<=350;i=i+70)
{
  button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
  button.frame=CGRectMake(30,i,35,40);
  [button addTarget:self action:@selector(buttonclicked:) forControlEvents:UIControlEventTouchUpInside];
  if (k<[array1 count])
  {
    [button setTitle:[array1 objectAtIndex:k] forState:UIControlStateNormal];
  }
  k++;  
  [self.view addSubview:button]; 
}

```

Answer: 
Plain old way !

Include:

```
#include <wininet.h>
#pragma comment(lib,"Wininet.lib")

```

In your Method:

```
char url[128];
strcat(url, "http://www.techtoolbox.com");
bool bConnect = InternetCheckConnection(url, FLAG_ICC_FORCE_CONNECTION, 0);

if (bConnect)
{
    //internet connection exists !
}
else
{
            //internet DOES NOT connection exists !
}

```

Hope it helps.
In my opinion a way is to create a socket and try connecting a known host. These links will help:
For windows: <http://msdn.microsoft.com/en-us/library/ms740673(VS.85).aspx> and for unix <http://www.tenouk.com/cnlinuxsockettutorials.html>.

HTH   

Anil