Reputation: 21
I am storing a video file of size more than 1 GB and storing into homeDirectory. I am trying to convert into NSData object as follows
NSData *videoData = [[NSData alloc] initWithContentsOfFile:filePath];
but here I am getting video data as nil. When I tried for video of 500 MB it is working fine.
Is there any limitation on size while converting into NSData?
Upvotes: 2
Views: 1251
Reputation: 95405
Try using this (requires iOS 5.0 or later):
NSError *error = nil;
NSData *data = [[NSData alloc] initWithContentsOfFile:filePath
options:NSDataReadingMappedIfSafe
error:&error];
Prior to iOS 5.0 you can use:
NSData *data = [[NSData alloc] initWithContentsOfMappedFile:filePath];
These will map the file into virtual memory if it is safe, which will significantly reduce the amount of memory used overall.
Upvotes: 8