This is not a Core Bluetooth based problem you have here.
For debugging, you could use
NSLog(@"%@", payload);
For your string to NSData conversion, your approach seems very complicated. I would suggest something simple like
NSData* payload = [iData[uuid] dataUsingEncoding:NSUTF8StringEncoding];
if (payload.length > 20)
{
// handle error. most LE peripherals don't support longer values.
}
Another error could be that you mix ASCII 0 '0'
with a binary zero '\0'
when writing your value.