title: How to filter the array by multiple element and find the sum in Swift?
body: <p>I'm trying to filter my array by some element. I want recordtype is contain "Income" and createdAt equal to a date but <code>$0.createdAt!</code> is an date type so I can't use <code>.contain("")</code>, what can I use?</p>
  
  <pre><code>recordFilter = record.filter { $0.recordtype!.contains("Income") /*|| $0.createdAt! = recordItem.createdAt!*/}
  </code></pre>
  
  <p>recordFilter output: (this result is not filter by createdAt yet)</p>
  
  <pre><code>[&lt;Record: 0x600000099fa0&gt; (entity: Record; id: 0xd0000000003c0000 &lt;x-coredata://913F25A5-B2C9-4646-9091-5EFE7F906908/Record/p15&gt; ; data: {
      accountbook = "first book";
      amount = "\U00a59.99";
      assest = nil;
      category = "\U6295\U8d44";
      createdAt = "2017-11-16 16:00:00 +0000";
      date = nil;
      id = 15;
      recordtype = "\U6536\U5165";
      remark = "";
      toAccBook = nil;
  }), &lt;Record: 0x600000099ff0&gt; (entity: Record; id: 0xd000000000400000 &lt;x-coredata://913F25A5-B2C9-4646-9091-5EFE7F906908/Record/p16&gt; ; data: {
      accountbook = "first book";
      amount = "\U00a56.58";
      assest = nil;
      category = "\U5de5\U8d44";
      createdAt = "2017-11-16 16:00:00 +0000";
      date = nil;
      id = 16;
      recordtype = "\U6536\U5165";
      remark = "";
      toAccBook = nil;
  })]
  </code></pre>
  
  <p>After that, I trying to get all the amount string in array and sum it. But I found that it's all separate string when I use this code, how can I group it in array and sum it or have any other way to do it?</p>
  
  <pre><code>let sum = recordFilter.map({Int($0.amount!.dropFirst())})
  //[nil, nil]
  
  for i in 0..&lt;recordFilter.count{
      if recordFilter[i].amount != nil{
  
          let amountList = recordFilter[i].amount!.dropFirst()
          print(amountList) // I found that it's separate string.
          //9.99
          //11.22
          // ...
  
          //let intArray = amountList.map { Int($0)!}
          //let sum = amountList.reduce(0, +)
          //print(sum)
  
      }
  }
  </code></pre>