Split NSData objects into other NSData objects with a given size

Posted by Cedric Vandendriessche on Stack Overflow See other posts from Stack Overflow or by Cedric Vandendriessche
Published on 2010-05-24T17:47:35Z Indexed on 2010/05/24 17:51 UTC
Read the original article Hit count: 554

Filed under:
|
|
|

I'm having an NSData object of approximately 1000kb big. Now I want to transfer this via bluetooth. This would be better if I have let's say 10 objects of 100kb. It comes to mind that I should use the -subdataWithRange: method of NSData.

I haven't really worked with NSRange. Well I know how it works, but then to read from a given location with the length: 'to end of file'... I've no idea how to do that.

Some code on how to split this into multiple 100kb NSData objects would really help me out here. (it probably involves the length method to see how many objects should be made..?)

Thank you in advance.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk