Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Map and Object documentation #8306

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions Realm/RLMApp.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,7 @@ - (instancetype)init {
self.enableSessionMultiplexing = true;
self.encryptMetadata = !getenv("REALM_DISABLE_METADATA_ENCRYPTION") && !RLMIsRunningInPlayground();
RLMNSStringToStdString(_clientConfig.base_file_path, RLMDefaultDirectoryForBundleIdentifier(nil));

_config.device_info.sdk = "Realm Swift";

// Platform info isn't available when running via `swift test`.
// Non-Xcode SPM builds can't build for anything but macOS, so this is
// probably unimportant for now and we can just report "unknown"
auto processInfo = [NSProcessInfo processInfo];
RLMNSStringToStdString(_config.device_info.platform_version,
[processInfo operatingSystemVersionString] ?: @"unknown");
RLMNSStringToStdString(_config.device_info.sdk_version, REALM_COCOA_VERSION);
configureSyncConnectionParameters(_config);
}
return self;
}
Expand All @@ -139,7 +130,6 @@ - (instancetype)initWithBaseURL:(nullable NSString *)baseURL
self.localAppName = localAppName;
self.localAppVersion = localAppVersion;
self.defaultRequestTimeoutMS = defaultRequestTimeoutMS;
configureSyncConnectionParameters(_config);
}
return self;
}
Expand All @@ -153,6 +143,9 @@ static void configureSyncConnectionParameters(realm::app::App::Config& config) {
config.device_info.sdk = "Realm Swift";
RLMNSStringToStdString(config.device_info.sdk_version, REALM_COCOA_VERSION);

// Platform info isn't available when running via `swift test`.
// Non-Xcode SPM builds can't build for anything but macOS, so this is
// probably unimportant for now and we can just report "unknown"
auto processInfo = [NSProcessInfo processInfo];
RLMNSStringToStdString(config.device_info.platform_version,
[processInfo operatingSystemVersionString] ?: @"unknown");
Expand Down
2 changes: 2 additions & 0 deletions Realm/RLMDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ RLM_HEADER_AUDIT_BEGIN(nullability, sendability)
`RLMDictionary`s cannot be created directly. `RLMDictionary` properties on `RLMObject`s are
lazily created when accessed, or can be obtained by querying a Realm.

`RLMDictionary` only supports `NSString` as a key. Realm disallows the use of `.` or `$` characters within a dictionary key.

### Key-Value Observing

`RLMDictionary` supports dictionary key-value observing on `RLMDictionary` properties on `RLMObject`
Expand Down
4 changes: 2 additions & 2 deletions RealmSwift/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ extension String: _MapKey { }

- Note: Optional versions of the above types *except* `Object` are only supported in non-synchronized Realms.

Map only supports String as a key.
Map only supports `String` as a key. Realm disallows the use of `.` or `$` characters within a dictionary key.

Unlike Swift's native collections, `Map`s is a reference types, and are only immutable if the Realm that manages them
is opened as read-only.

Expand Down
18 changes: 10 additions & 8 deletions RealmSwift/Object.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,11 @@ extension Object: _RealmCollectionValueInsideOptional {
transaction is committed.

If no key paths are given, the block will be executed on any insertion,
modification, or deletion for all object properties and the properties of
any nested, linked objects. If a key path or key paths are provided,
then the block will be called for changes which occur only on the
provided key paths. For example, if:
modification, or deletion for all object first-level properties of the object.
`Object` notifications are shallow by default, any nested property modification
will not trigger a notification, unless the key path to that property is specified.
If a key path or key paths are provided, then the block will be called for
changes which occur only on the provided key paths. For example, if:
```swift
class Dog: Object {
@Persisted var name: String
Expand Down Expand Up @@ -338,10 +339,11 @@ extension Object: _RealmCollectionValueInsideOptional {
transaction is committed.

If no key paths are given, the block will be executed on any insertion,
modification, or deletion for all object properties and the properties of
any nested, linked objects. If a key path or key paths are provided,
then the block will be called for changes which occur only on the
provided key paths. For example, if:
modification, or deletion for all object first-level properties of the object.
`Object` notifications are shallow by default, any nested property modification
will not trigger a notification, unless the key path to that property is specified.
If a key path or key paths are provided, then the block will be called for
changes which occur only on the provided key paths. For example, i
```swift
class Dog: Object {
@Persisted var name: String
Expand Down
Loading