私はCocoaでスレッドを使用する方法を知りたがっています。私はこれを初めて知ったので、私はよくその文書を理解していません。NSThreadsをCocoaで使用していますか?
コードの上半分はタイミング用で、下半分は日付用です。誰も私にどのように1つのスレッドを使用する方法と2つのスレッドを使用して両方の操作を処理することができます。
NSDateFormatter *timeFormatter = [[[NSDateFormatter alloc] init] autorelease];
[timeFormatter setDateStyle:NSDateFormatterNoStyle];
[timeFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSDate *stringTime = [NSDate date];
NSString *formattedDateStringTime = [timeFormatter stringFromDate:stringTime];
time.text = formattedDateStringTime;
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
NSDate *stringDate = [NSDate date];
NSString *formattedDateStringDate = [dateFormatter stringFromDate:stringDate];
date.text = formattedDateStringDate;
正しく答えるのは難しい質問です。メインスレッド以外のスレッドからNSDateFormatterを使用しないでください。別の例で言い換えるとよいでしょう。 –
NSDateFormatterを別のスレッドで使用できないのはなぜですか?私はそれを指示する文書に何も表示されません。 –