开发者

Creating a directory in the iPhone

I want to create a sub folder to store the images which is captured by camera & also require to store images in to the database and retrieve the images From the database.

So please provide me help regarding how to create a folder开发者_Python百科 in iPhone & how to store the images in to the database & retrieve them


To create a directory in the documents folder,

- (void)createDirectoryInDocumentsFolderWithName:(NSString *)dirName {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *yourDirPath = [documentsDirectory stringByAppendingPathComponent:dirName];     
    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL isDir = YES;
    BOOL isDirExists = [fileManager fileExistsAtPath:yourDirPath isDirectory:&isDir];
    if (!isDirExists) [fileManager createDirectoryAtPath:yourDirPath withIntermediateDirectories:YES attributes:nil error:nil];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜