title: Cannot add a child that has a parent; detach or copy first
body: <p>I have a chat app, and i use below code to create a fixed message for a conversational partner when i block him :</p>
  
  <pre><code> NSString *deliveryMessage = [NSString stringWithFormat:@"{ \"sender\":\"%@\", \"senderUserName\":\"%@\", \"groupId\":\"%@\", \"messageType\":\"%@\"}", [USER_DEFAULT valueForKey:WA_USER_ID_KEY], [USER_DEFAULT valueForKey:WA_USER_NAME_KEY], stringId, @"block"];
  NSString *recieverJid =  [NSString stringWithFormat:@"%@@%@/%@", stringId ,CHAT_SERVER_ADDRESS,CHAT_SERVER_ADDRESS];
  
  NSString *senderJid = [NSString stringWithFormat:@"%@@%@/%@",MY_USER_NAME,CHAT_SERVER_ADDRESS,CHAT_SERVER_ADDRESS];
  
  NSXMLElement *body = [[NSXMLElement alloc]initWithName:@"body"];
  [body setStringValue:deliveryMessage];
  
  NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
  
  [message addAttributeWithName:@"type" stringValue:@"chat"];//@"chat"
  [message addAttributeWithName:@"from" stringValue:senderJid];
  [message addAttributeWithName:@"to" stringValue:recieverJid];
  [message addChild:[body copy]];
  
  [xmppStream sendElement:message];
  </code></pre>
  
  <p>Always it's crashing with error :<code>Cannot add a child that has a parent; detach or copy first</code></p>
  
  <p>I used same code for send messages between users and for other future. Always works, but here not.</p>
  
  <p>Any ideas? Thanks!</p>
  
  <p>EDIT!!
  My problem was because receiver was blocked with <code>XMPPPrivacy</code>. So I cannot send a message to him. After i remove the privacy all works again. </p>
  
  <p>If someone meet same problem, check if the receiver is blocked.</p>
  
  <p>Thanks to all!!!</p>