MutableSet
public final class MutableSet<Element> : RLMSwiftCollectionBase, RealmCollectionImpl where Element : RealmCollectionValue
extension MutableSet: ObservableObject, RealmSubscribable
extension MutableSet: _ObjcBridgeable
extension MutableSet: _RealmSchemaDiscoverable, SchemaDiscoverable where Element: _RealmSchemaDiscoverable
extension MutableSet: _HasPersistedType, _Persistable, _DefaultConstructible where Element: _Persistable
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, MutableSets 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>.
Properties of MutableSet type defined on Object subclasses must be declared as let and cannot be dynamic.
-
Creates a
MutableSetthat holds Realm model objects of typeElement.Declaration
Swift
public override init()
-
Returns an
Arraycontaining the results of invokingvalueForKey(_:)usingkeyon each of the collection’s objects.Declaration
Swift
@nonobjc public func value(forKey key: String) -> [AnyObject]
-
Warning
Ordering is not guaranteed on a MutableSet. Subscripting is implement convenience should not be relied on.Declaration
Swift
public subscript(position: Int) -> Element { get }
-
Returns a Boolean value indicating whether the Set contains the given object.
Declaration
Swift
public func contains(_ object: Element) -> BoolParameters
objectThe element to find in the MutableSet.
-
Returns a Boolean value that indicates whether this set is a subset of the given set.
Declaration
Swift
public func isSubset(of possibleSuperset: MutableSet<Element>) -> BoolParameters
objectAnother MutableSet to compare.
-
Returns a Boolean value that indicates whether this set intersects with another given set.
Declaration
Swift
public func intersects(_ otherSet: MutableSet<Element>) -> BoolParameters
objectAnother MutableSet to compare.
-
Inserts an object to the set if not already present.
Warning
This method may only be called during a write transaction.
Declaration
Swift
public func insert(_ object: Element)Parameters
objectAn object.
-
Inserts the given sequence of objects into the set if not already present.
Warning
This method may only be called during a write transaction.Declaration
Swift
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.
Declaration
Swift
public func remove(_ object: Element)Parameters
objectThe object to remove.
-
Removes all objects from the set. The objects are not removed from the Realm that manages them.
Warning
This method may only be called during a write transaction.Declaration
Swift
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.
Declaration
Swift
public func formIntersection(_ other: MutableSet<Element>)Parameters
otherAnother set.
-
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.
Declaration
Swift
public func subtract(_ other: MutableSet<Element>)Parameters
otherAnother set.
-
Inserts the elements of the given sequence into the set.
Warning
This method may only be called during a write transaction.
Declaration
Swift
public func formUnion(_ other: MutableSet<Element>)Parameters
otherAnother set.
-
Returns a human-readable description of the objects contained in the MutableSet.
Declaration
Swift
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.
Declaration
Swift
public var objectWillChange: RealmPublishers.WillChange<MutableSet> { get }
-
Undocumented
Declaration
Swift
public static var _rlmType: PropertyType { get } -
Undocumented
Declaration
Swift
public static var _rlmOptional: Bool { get } -
Undocumented
Declaration
Swift
public static var _rlmRequireObjc: Bool { get } -
Undocumented
Declaration
Swift
public static func _rlmPopulateProperty(_ prop: RLMProperty)
-
Undocumented
Declaration
Swift
public typealias PersistedType = MutableSet -
Undocumented
Declaration
Swift
public static var _rlmRequiresCaching: Bool { get } -
Undocumented
Declaration
Swift
public static func _rlmGetProperty(_ obj: ObjectBase, _ key: UInt16) -> Self -
Undocumented
Declaration
Swift
public static func _rlmSetProperty(_ obj: ObjectBase, _ key: UInt16, _ value: MutableSet) -
Undocumented
Declaration
Swift
public static func _rlmSetAccessor(_ prop: RLMProperty)
-
Declaration
Swift
public convenience init(from decoder: Decoder) throws
-
MutableSetElementMappertransforms the actualMutableSetofObjectsorMutableSetofEmbeddedObjectsin toProjectedCollection.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 viaprojectToNote: This is not the actual set data type therefore projected elements can contain duplicates.Declaration
Swift
public var projectTo: CollectionElementMapper<Element> { get }
View on GitHub
Install in Dash