开发者

how to store file contents to iphone's internal memory using xcode?

开发者 https://www.devze.com 2023-02-22 04:51 出处:网络
how to store file contents to ip开发者_运维问答hone\'s internal memory using xcode ? I want to store XML file to iPhone\'s internal memory.You can read hold the xml data in NSData and store the file

how to store file contents to ip开发者_运维问答hone's internal memory using xcode ?

I want to store XML file to iPhone's internal memory.


You can read hold the xml data in NSData and store the file in private folder ( avaible only for application )

below is code for saving file

NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSMutableString* str = [[NSMutableString alloc] initWithCapacity:300];
        [str appendString:documentsDirectory];
        [str appendString:@"/"];
        [str appendString:aName];

        NSFileManager *fileManager = [NSFileManager defaultManager];
        [/*NSData*/ writeToFile:str atomically:YES];

        if(str)
        {
            [str release];
            str = nil;

        }
        if(fileManager)
        {
            [fileManager release];
            fileManager = nil;
        }

        [pool release];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号