public final class MutableSet<Element> : RLMSwiftCollectionBase, RealmCollectionImpl where Element : RealmCollectionValue
extension MutableSet: ObservableObject, RealmSubscribable
extension MutableSet: Decodable where Element: Decodable
extension MutableSet: Encodable where Element: Encodable
MutableSet
is the container type in Realm used to define to-many relationships with distinct values as objects.
Like Swift’s Set
, MutableSet
is a generic type that is parameterized on the type it stores. This can be either an Object
subclass or one of the following types: Bool
, Int
, Int8
, Int16
, Int32
, Int64
, Float
, Double
, String
, Data
, Date
, Decimal128
, and ObjectId
(and their optional versions)
Unlike Swift’s native collections, MutableSet
s are reference types, and are only immutable if the Realm that manages them is opened as read-only.
MutableSet’s can be filtered and sorted with the same predicates as Results<Element>
.
Creates a MutableSet
that holds Realm model objects of type Element
.
Swift
public override init()
Returns an Array
containing the results of invoking valueForKey(_:)
using key
on each of the collection’s objects.
Swift
@nonobjc
public func value(forKey key: String) -> [AnyObject]
Swift
public subscript(position: Int) -> Element { get }
Returns a Boolean value indicating whether the Set contains the given object.
DeclarationSwift
public func contains(_ object: Element) -> Bool
Parameters object
The element to find in the MutableSet.
Returns a Boolean value that indicates whether this set is a subset of the given set.
DeclarationSwift
public func isSubset(of possibleSuperset: MutableSet<Element>) -> Bool
Parameters object
Another MutableSet to compare.
Returns a Boolean value that indicates whether this set intersects with another given set.
DeclarationSwift
public func intersects(_ otherSet: MutableSet<Element>) -> Bool
Parameters object
Another MutableSet to compare.
Inserts an object to the set if not already present.
Warning
This method may only be called during a write transaction.
DeclarationSwift
public func insert(_ object: Element)
Inserts the given sequence of objects into the set if not already present.
Warning
DeclarationSwift
public func insert<S>(objectsIn objects: S) where Element == S.Element, S : Sequence
Removes an object in the set if present. The object is not removed from the Realm that manages it.
Warning
This method may only be called during a write transaction.
DeclarationSwift
public func remove(_ object: Element)
Parameters object
The object to remove.
Removes all objects from the set. The objects are not removed from the Realm that manages them.
Warning
DeclarationSwift
public func removeAll()
Mutates the set in place with the elements that are common to both this set and the given sequence.
Warning
This method may only be called during a write transaction.
DeclarationSwift
public func formIntersection(_ other: MutableSet<Element>)
Mutates the set in place and removes the elements of the given set from this set.
Warning
This method may only be called during a write transaction.
DeclarationSwift
public func subtract(_ other: MutableSet<Element>)
Inserts the elements of the given sequence into the set.
Warning
This method may only be called during a write transaction.
DeclarationSwift
public func formUnion(_ other: MutableSet<Element>)
Returns a human-readable description of the objects contained in the MutableSet.
DeclarationSwift
public override var description: String { get }
A publisher that emits Void each time the collection changes.
Despite the name, this actually emits after the collection has changed.
DeclarationSwift
public var objectWillChange: RealmPublishers.WillChange<MutableSet> { get }
Element
: Decodable
Swift
public convenience init(from decoder: Decoder) throws
MutableSetElementMapper
transforms the actual MutableSet
of Objects
or MutableSet
of EmbeddedObjects
in to ProjectedCollection
.
For example:
class Person: Object {
@Persisted var dogs: MutableSet<Dog>
}
class PersonProjection: Projection<Person> {
@Projected(\Person.dogs.projectTo.name) var dogNames: ProjectedCollection<String>
}
In this code the Person
‘s dogs set will be prijected to the projected set of dogs names via projectTo
Note: This is not the actual set data type therefore projected elements can contain duplicates.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4