# Chapter 4: Using a list of strings to reference other objects

**URL:** <https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245>\
**Category:** Realm: Building Modern Swift Apps with Realm\
**Created:** [August 24, 2018, 4:01pm UTC](https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245 "2018-08-24T16:01:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![perlguy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/perlguy/32/108860_2.png) [@perlguy](https://forums.kodeco.com/u/perlguy)\
**Post date:** [August 24, 2018, 4:01pm UTC](https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245/1 "2018-08-24T16:01:15Z")

</div>

I’m working through the example with the “stickers” on the car. In the book, they show just one sticker being referenced and printed.

I tried adding a few other stickers. While the `print(car.stickers)` correctly lists all of the stickers in the list - the `print(realm.objects(Sticker.self).filter("id IN %@", car.stickers))` only lists the first sticker.

Is this how it is supposed to work? I would assume that the filter command would end up listing all of the stickers instead of just the first one.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [September 1, 2018, 4:43am UTC](https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245/2 "2018-09-01T04:43:08Z")

</div>

@freak4pc Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![icanzilb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/icanzilb/32/109333_2.png) [@icanzilb](https://forums.kodeco.com/u/icanzilb)\
**Post date:** [September 1, 2018, 7:26am UTC](https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245/3 "2018-09-01T07:26:57Z")

</div>

Check again your code, if you don’t see all the linked stickers maybe you’ve missed something. Here’s how to update the example in Chapter 4 to list 2 stickers instead of one:

```swift
Example.of("Referencing objects from a different Realm file") {
  // let's say we're storing those in "stickers.realm"
  let sticker = Sticker("Swift is my life")
  let sticker2 = Sticker("Xcode rocks")

  car.stickers.append(sticker.id)
  car.stickers.append(sticker2.id)

  print(car.stickers)

  try! realm.write {
    realm.add(car)
    realm.add(sticker)
    realm.add(sticker2)
  }

  print("Linked stickers:")
  print(realm.objects(Sticker.self)
    .filter("id IN %@", car.stickers))
}

```

This outputs:

```nohighlight
ℹ️ Referencing objects from a different Realm file:
————————————————————————————————————————————————————————————
List<string> <0x608000045fa0> (
	[0] 05431193-93F4-44EF-BCA1-61437A9BE7A3,
	[1] 0D0914CE-BA34-46AC-ACE4-95D282DCDAF5
)
Linked stickers:
Results<Sticker> <0x7fa9e270dad0> (
	[0] Sticker {
		id = 05431193-93F4-44EF-BCA1-61437A9BE7A3;
		text = Swift is my life;
	},
	[1] Sticker {
		id = 0D0914CE-BA34-46AC-ACE4-95D282DCDAF5;
		text = Xcode rocks;
	}
)

```

---

<div class="post-metadata">

**Author:** ![freak4pc](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/freak4pc/32/101113_2.png) [@freak4pc](https://forums.kodeco.com/u/freak4pc)\
**Post date:** [September 1, 2018, 9:50am UTC](https://forums.kodeco.com/t/chapter-4-using-a-list-of-strings-to-reference-other-objects/47245/4 "2018-09-01T09:50:56Z")

</div>

Seems like @icanzilb already took care of it 🙂
