macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initWithString:calendarFormat:

文字列でカレンダー日付を初期化して返します
-(id)initWithString:(NSString *)description:
             calendarFormat:(NSString *)format:

解説

文字列でカレンダー日付を初期化して返します。
フォーマットに合わなければnilを返します。

返り値

( id )

カレンダー日付/nil

引数

( NSString * )description
( NSString * )format

フォーマット

クラス

NSCalendarDate

Instance Methods

使用可能

10.0

参照

+ dateWithString:calendarFormat:
- calendarFormat

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSCalendarDate *theDate = [[NSCalendarDate alloc]
    initWithString:@"Sunday, 26 May 2002, 05:28 PM" 
    calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
     
NSLog([theDate description]);
}

@end