Skip to content

Instantly share code, notes, and snippets.

View tomohisa's full-sized avatar

Tomohisa Takaoka tomohisa

View GitHub Profile
@tomohisa
tomohisa / Extract URLs out of NSString
Created December 15, 2010 18:58
Using NSDataDetector NSTextCheckingTypeLink
@interface NSString (url)
- (NSMutableArray*) extractURLs ;
@end
@implementation NSString (url)
- (NSMutableArray*) extractURLs {
NSString* source = self;
NSDataDetector* detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
NSArray* matches = [detector matchesInString:source options:0 range:NSMakeRange(0, [source length])];
LOG([matches description]);
NSMutableArray* urls = [NSMutableArray arrayWithCapacity:0];
@tomohisa
tomohisa / ViewController.m
Created October 13, 2011 04:47
test for synthesize
//
// ViewController.m
// test
//
// Created by Tomohisa Takaoka on 10/12/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
@tomohisa
tomohisa / gist:1388038
Created November 23, 2011 06:44
how to change in app language settings.
// need to restart app
languages = [NSArray arrayWithObjects:@"en",@"ja",nil];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
@tomohisa
tomohisa / KKAdBanner.h
Created November 28, 2011 12:19
KKAdBanner Active Ad Change.
/*
* Kobold2D™ --- http://www.kobold2d.org
*
* Copyright (c) 2010-2011 Steffen Itterheim.
* Copyright (c) 2011 Simon Jewell (http://blog.sygem.com)
* Released under MIT License in Germany (LICENSE-Kobold2D.txt).
*/
#import <Availability.h>
#import "cocos2d.h"
@tomohisa
tomohisa / gist:2330673
Created April 7, 2012 17:32
rotate table
tableTweet.autoresizingMask = UIViewAutoresizingNone;
CGRect area2 = {0,adView.frame.origin.y+adviewHeight,self.view.bounds.size.width,self.view.bounds.size.height-(adviewHeight)};
tableTweet.transform = CGAffineTransformMakeRotation(M_PI *(-90) / 180.0f);
tableTweet.frame=area2;
tableHeight = TOVData.columnWidth;
tableWidth = tableTweet.frame.size.height;
[TOVTweetView setMaximumHeight:tableWidth];
tweetViews = [NSMutableArray arrayWithCapacity:0];
[self renewNodes];
[tableTweet reloadData];
@tomohisa
tomohisa / gist:2331057
Created April 7, 2012 18:10
Updated still same result... rotate table view but doesn't detect touch on top...
tableTweet.autoresizingMask = UIViewAutoresizingNone;
CGRect area2 = {0,adView.frame.origin.y+adviewHeight,self.view.bounds.size.width,self.view.bounds.size.height-(adviewHeight)};
CGPoint center = CGPointMake(area2.origin.x+area2.size.width/2, area2.origin.y+area2.size.height/2);
tableTweet.frame = CGRectMake(0, 0,area2.size.width, area2.size.height);
tableTweet.center = center;
tableTweet.transform = CGAffineTransformMakeRotation(M_PI *(-90) / 180.0f);
tableTweet.center = center;
@tomohisa
tomohisa / gist:2355465
Created April 10, 2012 23:11
Check and open Twitter URL Scheme
NSString *str = [NSString stringWithFormat:@"twitter://user?screen_name=%@", bstr];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:str]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}else {
UIAlertView*alert = [[UIAlertView alloc] initWithTitle:@"Tweetoverview" message:NSLocalizedString(@"Can not open twitter app. Please install twitter app to send tweet.", @"Can not open twitter app. Please install twitter app to send tweet.") delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
@tomohisa
tomohisa / gist:2665336
Created May 12, 2012 08:59
paint code variable size sample
- (void)drawRect:(CGRect)rect
{
//// General Declarations
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* color = [UIColor colorWithRed: 0.3 green: 0.3 blue: 0.3 alpha: 1];
UIColor* color2 = [UIColor colorWithRed: 0.1 green: 0.1 blue: 0.1 alpha: 1];
UIColor* color3 = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.69];
@tomohisa
tomohisa / TOVAppDelegate.h
Created May 19, 2012 08:31
How to Keep Main Data on AppDelegate
+(TOVAppDelegate*)sharedDelegate;
+(TOVModel*)sharedModel;
@tomohisa
tomohisa / gist:2897676
Created June 8, 2012 19:20
Add and Remove ChildViewController
// add child view
UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
[self addChildViewController:controller];
controller.view.frame = CGRectMake(0, 44, 320, 320);
[self.view addSubview:controller.view];
[controller didMoveToParentViewController:self];
// remove child view
UIViewController *vc = [self.childViewControllers lastObject];
[vc.view removeFromSuperview];