# Counting the amount of attributes saved from core data helper class

**URL:** <https://forums.kodeco.com/t/counting-the-amount-of-attributes-saved-from-core-data-helper-class/181304>\
**Category:** Swift\
**Created:** [November 30, 2022, 5:00am UTC](https://forums.kodeco.com/t/counting-the-amount-of-attributes-saved-from-core-data-helper-class/181304 "2022-11-30T05:00:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timswift](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/timswift/32/110937_2.png) [@timswift](https://forums.kodeco.com/u/timswift)\
**Post date:** [November 30, 2022, 5:00am UTC](https://forums.kodeco.com/t/counting-the-amount-of-attributes-saved-from-core-data-helper-class/181304/1 "2022-11-30T05:00:46Z")

</div>

n my swift code below the goal is to get the amount of core data attributes saved into core data. I am receiving the error message **No exact matches in call to initializer** at **indexBox.text = String(info?)**. I don’t know what to do next.

```auto
class ViewController: UIViewController {
  override func viewDidLoad() {
        super.viewDidLoad()
   let info = CoredataHandler.fetchObject()?.count
        
 
        
            indexBox.text = String(info?)
        
     
        
     
        
    }
}

class CoredataHandler : NSManagedObject {
    class func fetchObject() -> [User]?
    {
        let context = getContext()
        var user : [User]? = nil
        do {
            user = try context.fetch(User.fetchRequest())
            
            return user
            
        } catch {
            return user
        }
        
    }
    
}

```

---

<div class="post-metadata">

**Author:** ![robertomachorro](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/robertomachorro/32/111603_2.png) [@robertomachorro](https://forums.kodeco.com/u/robertomachorro)\
**Post date:** [November 30, 2022, 12:38pm UTC](https://forums.kodeco.com/t/counting-the-amount-of-attributes-saved-from-core-data-helper-class/181304/2 "2022-11-30T12:38:58Z")

</div>

Set a breakpoint in that line and check the value for _info_. Is it nil? if so, then you should have a coalescent value for when there isn’t a value there to display:

```swift
info ?? 0

```

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [May 15, 2023, 9:00pm UTC](https://forums.kodeco.com/t/counting-the-amount-of-attributes-saved-from-core-data-helper-class/181304/3 "2023-05-15T21:00:48Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
