objective c - How can append Data to NSmutableData in Cocoa -


i want add new nsdata = x20 (ascii) , it's space @ last in nsmutabledata enough fixed byes. example: nsmuatabledata has 400 bytes, need nsmutabledata has 600 bytes. want add 200 byes (x20 in hex) @ last nsmutabledata. how can that? please me. in advance

// write xmldoc file nsdata* xmldata = [xmldoc xmldatawithoptions:nsxmlnodepreserveall]; nslog(@"xmldata %@",xmldata); nsmutabledata * datawrite = [xmldata mutablecopy ] ; nsarray *array = [[nsarray alloc] init]; // dont know how add x20 (hex) array  [datawrite appenddata:[[nsstring stringwithformat:@"%@", array] datausingencoding:nsutf8stringencoding]]; 

nsmutabledata *datawrite = ... nsuinteger oldlength = [datawrite length]; nsuinteger newlength = 600; if (newlength > oldlength ) {     // extend mutable data object:     [datawrite setlength:newlength];      // fill appended bytes space characters:     char *bytes = [datawrite mutablebytes];     memset(bytes + oldlength, ' ', newlength - oldlength); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -