Upvote:2

Aprove answer
    NSMutableString *finalString = [[NSMutableString alloc] init];
    NSMutableString *binary;
    NSMutableString *binaryReversed;

    // The original string
    NSString *test = @"Test";

    char temp;
    int i, j, digit, dec;

    // Loop through all the letters in the original string
    for (i = 0; i < test.length; i++) {
        // Get the character
        temp = [test characterAtIndex:i];
        dec = (int)temp;
        binary = [[NSMutableString alloc] initWithString:@""];
        // Convert the decimal value to binary representation
        // getting the remainders and storing them in an NSString
        while (dec != 0) {
            digit = dec % 2;
            dec = dec / 2;
            [binary appendFormat:@"%d", digit];
        }
        // Reverse the bit sequence in the NSString
        binaryReversed = [[NSMutableString alloc] initWithString:@""];
        for (j = (int)(binary.length) - 1; j >= 0; j--) {
            [binaryReversed appendFormat:@"%C", [binary characterAtIndex:j]];
        }
        // Append the bit sequence to the current letter to the final string
        [finalString appendString:binaryReversed];
        [binaryReversed release];
        [binary release];
    }
    // Just show off the result and release the finalString
    NSLog(@"%@ in binary: %@", test, finalString);
    [finalString release];

Credit Goes to: stackoverflow.com

Related question with same questions but different answers