title: Objective-C - why adding two string is causing the crash?
body: <p>Appending new string to old string is causing crash. 
  (abnormally works if i do as like this <code>StructIOS.server = @""; StructIOS.server = [StructIOS.server stringByAppendingString:@".stackoverflow.com"];</code>).</p>
  
  <p>struct.h:</p>
  
  <pre><code>struct iOS {
    __unsafe_unretained NSString *input_url;
    __unsafe_unretained NSString *use_url;  
    __unsafe_unretained NSString *server;
  };
  struct iOS StructIOS;
  </code></pre>
  
  <p>ViewController.m:</p>
  
  <pre><code>StructIOS.use_url = @"relay/pincode/apicode/accesskey/1/2/3/99/../900";
  NSArray *work_array = [StructIOS.use_url componentsSeparatedByString:@"/"];
  StructIOS.server    = [work_array objectAtIndex:0];
  if([StructIOS.server length] &gt; 0) {
    NSLog(@"&gt;&gt;&gt; 4: %@", StructIOS.server); // OK!!
    StructIOS.server = [StructIOS.server stringByAppendingString:@".stackoverflow.com"]; // FAIL!!
    NSLog(@"&gt;&gt;&gt; 5: %@", StructIOS.server);  
  }
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>&gt;&gt;&gt; 4: relay
  crash
  </code></pre>
  
  <p><strong>Expected output:</strong></p>
  
  <pre><code>&gt;&gt;&gt; 5: relay.stackoverflow.com
  </code></pre>
  
  <p><strong>EDIT:</strong> following way worked without crash</p>
  
  <pre><code>NSString *fool_ios;
  
  // read from NSString type
  StructIOS.server = fool_ios;
  
  // save to NSString type
  fool_ios = StructIOS.server;
  </code></pre>