---
title: "How to Convert NSData length into MB in iOS?"  
description: "How to Convert NSData length into MB in iOS?"  
author: "Anonymous User"  
published: 2016-01-12  
updated: 2016-01-13  
canonical: https://www.mindstick.com/forum/33856/how-to-convert-nsdata-length-into-mb-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to Convert NSData length into MB in iOS?

Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) how can I [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) NSData [length](https://www.mindstick.com/interview/1915/what-is-the-difference-between-char_length-and-length) which is in bytes into megabytes.\
I want to [print](https://www.mindstick.com/blog/301752/types-of-3d-printing-technology) that [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in NSLog() like this:

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

above [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) will print bytes but I want to print length in MB.\
for example: **[Data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) length: 8 MB**

Please help me.

## Replies

### Reply by Tarun Kumar

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.\


---

Original Source: https://www.mindstick.com/forum/33856/how-to-convert-nsdata-length-into-mb-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
