Skip to content

Instantly share code, notes, and snippets.

@dmnlk
Created February 6, 2012 16:43
Show Gist options
  • Select an option

  • Save dmnlk/1753201 to your computer and use it in GitHub Desktop.

Select an option

Save dmnlk/1753201 to your computer and use it in GitHub Desktop.
sample
void setState(BOOL enable) // required; called when user presses toggle button
{
if (enable) // toggle is disabled, so enable it
{
char hostname[256];
int hostname_length=30;
gethostname(hostname,hostname_length);
NSLog(@"%s",hostname);
NSString *str =[NSString stringWithUTF8String:hostname];
av = [[UIAlertView alloc] initWithTitle:@"yourhost" message:str delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
UIPasteboard *paste = [UIPasteboard generalPasteboard];
[paste setString:str];
}
else // toggle is enabled, so disable it
{
av = [[UIAlertView alloc] initWithTitle:@"togglennn" message:@"Toggle Disabled" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
}
[av show];
isToggleEnabled = enable; // for getStateFast() use
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment