Skip to content

Instantly share code, notes, and snippets.

View shannoga's full-sized avatar

Shani Hajbi shannoga

View GitHub Profile
https://gist.github.com/1033072
CGRectGetWidth(startSegment.frame)
@shannoga
shannoga / gist:1008678
Created June 5, 2011 05:14
Get fonts family and font names list on iOS
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
@shannoga
shannoga / simplepastiefile.m
Created May 30, 2011 12:41
Get only numbers from NSString
+(NSString*)getOnlyNumbersFromString:(NSString*)stringToStrip{
NSMutableString *strippedString = [NSMutableString
stringWithCapacity:stringToStrip.length];
NSScanner *scanner = [NSScanner scannerWithString:stringToStrip];
NSCharacterSet *numbers = [NSCharacterSet
characterSetWithCharactersInString:@"0123456789"];
while ([scanner isAtEnd] == NO) {
NSString *buffer;
@shannoga
shannoga / simplepastiefile.m
Created May 30, 2011 12:36
Detect user languish
+(NSString*)currentLang{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
return [languages objectAtIndex:0];
}
@shannoga
shannoga / Is that an ipad
Created May 30, 2011 11:58
Is that an ipad
+ (BOOL)isDeviceAniPad {
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
return NO;
#endif
}