title: Modify an object value in array using swift
body: <p>i am new to swift.
  I want to know how to modify an object in a for-each loop using swift.
  for example:</p>
  
  <p>struct MyCustomObject 
  {
      var customValue: String?
  }</p>
  
  <p>let myArray: [MyCustomObject?]</p>
  
  <pre><code>for anObject:MyCustomObject in myArray {
      anObject.customValue = "Hello" // &lt;---Cannot assign to property: 'anObject' is a 'let' constant 
  }
  </code></pre>
  
  <p>so , what should I do if i want to change the object value in a for-loop.
  I tired adding "var" before anObject, but it doesnt work!! (the objects in the array still remain unchanged.)</p>
  
  <p>For objective C , it is easy,</p>
  
  <p>NSMutableArray * myArray = [NSMutableArray array];</p>
  
  <pre><code>for (MyCustomObject * object in myArray) 
  { 
    object.customValue = "Hello" 
  }
  </code></pre>