HOW TO CONVERT NSDATA LENGTH INTO MB IN IOS?

monica frank

Total Post:10

Points:70
Posted by  monica frank
 4826  View(s)
Ratings:
Rate this:

Can anyone tell me how can I convert NSData length which is in bytes into  megabytes.
I want to print that value in NSLog() like this:

NSLog(@"Data length: %u MB", imageData.length);

above code will print bytes but I want to print length in MB.
for example: Data length: 8 MB

Please help me.

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to Convert NSData length into MB in iOS?

    As we know that- in 1KB=1024 bytes and 1024KB in 1Megabyte.
    So, we can use your code like this:
    NSLog(@"Data length: %u MB",(imageData.length/1024/1024));
    Above we are provided the simplistic approach.

      Modified On Jan-13-2016 07:01:11 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!