macOS/iOS API解説

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

目次

writeToURL:ofType:

指定したURLと文書タイプでファイルに書き出します
-(BOOL)writeToURL:(NSURL *)anURL:
          ofType:(NSString *)type:

解説

指定したURLと文書タイプでファイルに書き出します。
ファイルのURLのみサポートします

返り値

( BOOL )

YES/NO

引数

( NSURL * )anURL

URL

( NSString * )type

文書タイプ

フレームワーク

ApplicationKit

クラス

NSDocument

Instance Methods

使用可能

10.0

参照

例文

- (IBAction)saveDocument:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[@"~/docSaveFile1" stringByExpandingTildeInPath]];
if ([url isFileURL]){
    if ([self writeToURL:url
                ofType:@"txt"
                ])
        {
        NSLog(@"YES");
        }else{
        NSLog(@"no");
        }
    }
}