Skip to content

Instantly share code, notes, and snippets.

View greenhouse's full-sized avatar

house greenhouse

  • A galaxy far far away
View GitHub Profile
@chancyWu
chancyWu / Forward Touches and Gestures to Views from UIScrollView
Last active August 29, 2015 14:02
Forward Touches and Gestures to Views from UIScrollView
// in your subclass of UIScrollView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.dragging) {
[self.nextResponder touchesBegan:touches withEvent:event];
}
else {
[super touchesBegan:touches withEvent:event];
}
@chancyWu
chancyWu / gist:46c0c8fd19550a1e7343
Last active August 29, 2015 14:02
NSLocale usage
NSLocale *lcl = [[NSLocale alloc] initWithLocaleIdentifier:@"en_SG"];
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];
[fmtr setNumberStyle:NSNumberFormatterCurrencyStyle];
[fmtr setLocale:lcl];
NSLog(@"Current Locale: %@", [NSLocale currentLocale]);
NSLog(@"Available Locales: %@",[NSLocale availableLocaleIdentifiers]);
NSLog( @"%@", [lcl displayNameForKey:NSLocaleCurrencySymbol value:@"en_SG"] );
NSLog( @"%@", [fmtr currencySymbol] );
NSLog(@"CurrencyCode: %@", [lcl objectForKey:NSLocaleCurrencyCode]);
- (void)showAlert:(NSString *)message
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
[alert show];
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:0.5];
}
- (void)dismissAlert:(UIAlertView *)alertView
{
[alertView dismissWithClickedButtonIndex:0 animated:YES];
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
- (void)broadCast
{
int socketSD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (socketSD <= 0) {
NSLog(@"Error: Could not open socket.");