Objective-C Append NSData to another NSData using NSMutableData

    NSData *d1;
    char c1[] = { 0x02, 0x03 };
    char c2[] = { 0x04, 0x05 };
    d1 = [NSData dataWithBytes:(char*)c1 length:2];
    NSMutableData *nd = [[NSMutableData alloc] initWithData:d1];
    NSLog(@"Before append: %@", d1);
    d1 = [NSData dataWithBytes:c2 length:2];
    [nd appendData:d1];
    NSLog(@"After append: %@", nd);
This entry was posted in Uncategorized. Bookmark the permalink.