Skip to content

Instantly share code, notes, and snippets.

#import <Foundation/Foundation.h>
@interface XMLReader : NSObject <NSXMLParserDelegate>
{
NSMutableArray *dictionaryStack;
NSMutableString *textInProgress;
NSError *errorPointer;
}
+ (NSDictionary *)dictionaryForPath:(NSString *)path error:(NSError *)errorPointer;
@myaaaaa-chan
myaaaaa-chan / file0.m
Created April 30, 2013 02:40
日付文字列をISO-8601形式のNSDate型に変換するコード ref: http://qiita.com/items/72a6f7e2ea62e2f0f163
NSString *dateString = [dic objectForKey:@"2013-04-30T11:30:00+09:00"];
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZZ"];
NSDate* date = [formatter dateFromString:dateString];
@myaaaaa-chan
myaaaaa-chan / file0.m
Created April 30, 2013 08:26
アプリからSafari起動し指定したURLを開く ref: http://qiita.com/items/63878b14eec03f7fdaf4
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.yahoo.co.jp/"]];
@myaaaaa-chan
myaaaaa-chan / file0.m
Created May 1, 2013 07:07
UIBarButtonItemのイメージを変更する ref: http://qiita.com/items/9753c0c8934212b3f282
// 変更後のイメージ
UIImage *img = [UIImage imageNamed:@"hoge"];
// 変更後のイメージを設定するボタン
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// イメージを設定
[button setImage:img forState:UIControlStateNormal];
// ボタンにターゲットを設定
@myaaaaa-chan
myaaaaa-chan / file0.m
Last active December 16, 2015 21:29
UIRefreshControlで引っ張って更新をする ref: http://qiita.com/myaaaaa_chan/items/fc3adb23d16171de5abe
- (void)viewDidLoad
{
[super viewDidLoad];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc]init];
// 更新アクションを設定
[refreshControl addTarget:self action:@selector(onRefresh:) forControlEvents:UIControlEventValueChanged];
// UITableViewControllerにUIRefreshControlを設定
@myaaaaa-chan
myaaaaa-chan / file0.m
Created May 9, 2013 07:18
xcode4で作ったplistのArrayを読み込む ref: http://qiita.com/items/7f35e47133ceab36dcdc
NSString *path = [[NSBundle mainBundle] pathForResource:@"config" ofType:@"plist"];
NSDictionary *propDictionary = [NSDictionary dictionaryWithContentsOfFile:path];
NSArray *array = [NSArray arrayWithArray:[propDictionary objectForKey:@"key"]];
@myaaaaa-chan
myaaaaa-chan / file0.m
Created May 9, 2013 09:51
SDWebImageで画像をダウンロードする ref: http://qiita.com/items/1198abc5351ca57a552c
#import "UIImageView+WebCache.h"
- (void)viewDidLoad
{
NSURL url = [NSURL URLWithString:@"http://hogehoge.com/hoge.png"];
[imageView setImageWithURL:url placeholderImage:nil options:SDWebImageCacheMemoryOnly];
}
@myaaaaa-chan
myaaaaa-chan / MyUILabel.m
Created May 10, 2013 02:02
UILabelを角丸にする&パディングを設定する方法 ref: http://qiita.com/items/cb168bd041c77ec54b0a
- (void)drawTextInRect:(CGRect)rect
{
// top, left, bottom, right
UIEdgeInsets insets = {0, 20, 0, 20};
return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}
@myaaaaa-chan
myaaaaa-chan / file0.m
Created May 10, 2013 08:26
UITableViewCellの背景色を変える ref: http://qiita.com/items/f13ef0d2266d1cf6c812
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = UIColor colorWithHue:0.61 saturation:0.09 brightness:0.99 alpha:1.0];
}
@myaaaaa-chan
myaaaaa-chan / file0.m
Created May 10, 2013 12:14
アプリケーションがバックグラウンドから復帰するときに任意の処理を呼び出す ref: http://qiita.com/items/b7f82079d3bb35dba68e
UIApplication *application = [UIApplication sharedApplication];
// アクティブになったときに通知されるように登録する
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hoge) name:UIApplicationDidBecomeActiveNotification object:application];