統計情報(30日間)


最新情報をツイート


人気の投稿

1st, 2nd、1 day ago, yesterday, 2,000 km Southwest など日付や数字、場所などを表示用に整形するライブラリ

このエントリーをはてなブックマークに追加



TTTArrayFormatter
配列を表示用に加工。
NSArray *list = [NSArray arrayWithObjects:@"Russel", @"Spinoza", @"Rawls", nil];
TTTArrayFormatter *arrayFormatter = [[[TTTArrayFormatter alloc] init] autorelease];
[arrayFormatter setUsesAbbreviatedConjunction:YES]; // Use '&' instead of 'and'
[arrayFormatter setUsesSerialDelimiter:NO]; // Omit Oxford Comma
NSLog(@"%@", [arrayFormatter stringFromArray:list]); // # => "Russell, Spinoza & Rawls"

TTTHoursOfOperation
共通の時間帯を日毎にまとめて表示。
Mon-Wed: 8:00AM - 7:00PM
Thu: 9:00AM - 12:00PM, 3:00PM - 10:00PM
Fri: Closed
Weekends: 11:00AM - 1:00AM

TTTLocationFormatter
2点間の位置情報を距離に換算して表示。
NSLog(@"%@", [locationFormatter stringFromDistanceAndBearingFromLocation:pittsburgh toLocation:austin]);
// "2,000 km Southwest"
NSLog(@"%@", [locationFormatter stringFromDistanceAndBearingFromLocation:pittsburgh toLocation:austin]);
// "1,218 miles SW"

TTTOrdinalNumberFormatter
1st, 2nd などの順序で表示。
NSLog(@"%@", [NSString stringWithFormat:NSLocalizedString(@"You came in %@ place!", nil), [ordinalNumberFormatter stringFromNumber:number]]);

English: "You came in 2nd place!"
French: "Vous êtes venu à la 2eme place!"
Spanish: "Usted llegó en 2.o lugar!"

TTTTimeIntervalFormatter
Twitterなどである◯時間前の表示。
TTTTimeIntervalFormatter *timeIntervalFormatter = [[TTTTimeIntervalFormatter alloc] init];
[timeIntervalFormatter stringForTimeInterval:0]; // "just now"
[timeIntervalFormatter stringForTimeInterval:100]; // "1 minute ago"
[timeIntervalFormatter stringForTimeInterval:8000]; // "2 hours ago"

// Turn idiomatic deictic expressions on / off
[timeIntervalFormatter stringForTimeInterval:100000]; // "yesterday"
[timeIntervalFormatter setUsesIdiomaticDeicticExpressions:NO];
[timeIntervalFormatter stringForTimeInterval:100000]; // "1 day ago"

// Customize the present tense deictic expression for
[timeIntervalFormatter setPresentDeicticExpression:@"seconds ago"];
[timeIntervalFormatter stringForTimeInterval:0]; // "seconds ago"

// Expand the time interval for present tense
[timeIntervalFormatter stringForTimeInterval:3]; // "3 seconds ago"
[timeIntervalFormatter setPresentTimeIntervalMargin:3];
[timeIntervalFormatter stringForTimeInterval:3]; // "seconds ago"

TTTURLRequestFormatter
cURL や Wget のコマンドライン引数を生成。
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.gowalla.com/spots"]] autorelease];
[request setHTTPMethod:@"POST"];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[TTTURLRequestFormatter cURLCommandFromURLRequest:request];
=> curl -X POST "https://api.gowalla.com/spots/" -H "Accept: application/json"

Leave a Reply