Questions tagged [nsmutabledata]

NSMutableData (and its superclass NSData) provide data objects, object-oriented wrappers for byte buffers. It is available in OS X v10.0 and later and available in iOS 2.0 and later .Use this tag [tag:NSMutableData] for questions referring to NSMutableData in OS X or iOS platform .

From Apple Official Document NSMutableData class reference (and its superclass NSData) provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects. They are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.

NSData creates static data objects, and NSMutableData creates dynamic data objects. You can easily convert one type of data object to the other with the initializer that takes an NSData object or an NSMutableData object as an argument.

For more information : NSMutableData Class Reference

Related SO Questions:

NSMutableData remove bytes?

Is it okay to call +[NSData dataWithData:] with an NSMutableData object?

Related tags:

155 questions
31
votes
4 answers

NSMutableData remove bytes?

I can add bytes to a NSMutableData instance easily by using the appendData method, however I do not see any similar method for removing data? Am I overlooking something, or do I need to create a new object and copy over only the bytes I need?
Kyle
  • 17,317
  • 32
  • 140
  • 246
14
votes
3 answers

iOS swift NSMutableData has no member appendString

Hello I am new to swift and I am following a tutorial and creating the same code in order to Upload an image . I am now using swift 3 and it seems like NSMutableData() no longer has the appendString method available what can I do as a substitute ?…
Rome Torres
  • 1,061
  • 2
  • 13
  • 27
13
votes
2 answers

Is it okay to call +[NSData dataWithData:] with an NSMutableData object?

Is it a problem for me to do the following to change a mutable data instance immutable? NSMutableData *mutData = [[NSMutableData alloc] init]; //Giving some value to mutData NSData *immutableData = [NSData dataWithData:mutData]; [mutData release];
Jackless
  • 171
  • 1
  • 2
  • 4
8
votes
4 answers

How to convert bytes to a float value in swift?

This is my code to convert byte data to float. I tried every answers given in this site. I am getting exponential value for this "<44fa0000>" byte data static func returnFloatValue(mutableData:NSMutableData)->Float { let qtyRange =…
Nisha Nair
  • 327
  • 1
  • 5
  • 17
6
votes
1 answer

combine nsdata objects into nsmutabledata object

I'm fairly sure I have to use NSMutableData for this problem as I will be accessing the object several times and adding each section of data once I have it. The problem I am faced with is that I am wanting to create one big NSMutableData object that…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
6
votes
1 answer

Convert NSMutableData to NSData in Swift

I have a method which is returning NSMutableData. I need to pass this NSMutableData to another method but that method is expecting only NSData. I am trying to find any method/solution to convert NSMutableData to NSdata. But still no luck. In…
Nitya
  • 449
  • 1
  • 8
  • 24
5
votes
1 answer

Insert bytes at front in NSMutableData

How can I insert a byte at the beginning of my NSMutableData? I understand that there is a replaceBytesInRange: method but that will just replace the bytes. There is a bunch of insertXAtIndex: methods but none are for bytes. How can I do this? One…
Milo
  • 5,041
  • 7
  • 33
  • 59
5
votes
2 answers

Different between NSData and NSMutableData in iPhone

What is the difference between NSData and NSMutableData?
Mr.savaliya
  • 259
  • 2
  • 8
4
votes
1 answer

NSMutableData Save to a File

I downloaed the file using code shown below. Then i am trying to save NSMutableData variable to file, however, the file is not created. What am i doing wrong? Do i need to convert NSMutableData into NSString? - (void)connection:(NSURLConnection…
user914425
  • 16,303
  • 4
  • 30
  • 41
4
votes
2 answers

Clear out contents in NSMutableData

I am new to Swift and iOS Development. How do we clear an NSMutableData without using release and then re-alloc/init again to be used again? I have tried resetBytesInRange() but that replaces the contents by zero. I tried data.length = 0, but there…
saurabh
  • 6,687
  • 7
  • 42
  • 63
4
votes
1 answer

cURL upload photo command in NSMutableURLRequest format

I know this may seem specific to the issue at hand, however, this is me trying to avoid the horrible UploadCare usage of cocoa pods which contains a significant (and rather outdated) amount of dependencies, to JUST upload a file (and subsequently…
Rambatino
  • 4,716
  • 1
  • 33
  • 56
3
votes
4 answers

New NSData with range of old NSData maintaining bytes

I have a fairly large NSData (or NSMutableData if necessary) object which I want to take a small chunk out of and leave the rest. Since I'm working with large amounts of NSData bytes, I don't want to make a big copy, but instead just truncate the…
umop
  • 2,122
  • 2
  • 18
  • 22
3
votes
1 answer

problems with NSMutabledata byteswithnocopy

I am trying to write a code to create NSMutableData from malloced buffer.I used freewhendone = YES 1) It gives an error in accessing the buffer after NSData is created.(in memset in below code) 2) The malloced buffer pointer and [data bytes] pointer…
thar_bun
  • 820
  • 1
  • 5
  • 20
3
votes
1 answer

how to concatenate multiple NSData?

My problem is the next> I have to receive data from an external accessory and save it into a big NSData, each time I receive a stream I have to copy that NSData into another one: CompleteNSData = NSDataTx1 + NSDataTx2 + NSDataTx3; and at the end…
3
votes
0 answers

NSMutableData appendBytes is setting length to -1 and crashing

I'm getting a rare and intermittent crash which looks like appendBytes being called with -1 as it's length. now, I've hard coded the "length" argument every time I've used this method so I can't see how this could happen and worse still I can't see…
1
2 3
10 11