Open reveelapp opened 3 years ago
@reveelapp Thank you for submitting this issue.
Can you provide a more detailed example of what you're doing? That would be very helpful.
At the minimum I'd like to understand what you do right before the line that fails and what realmURL
exactly is.
Thank you!
@DominicFrei
I am sorry, but I do not understand on what you mean by more details on the example. Since it is simply that one line of code that will not be allowed via Xcode. Since 'RLMBSON
' is the expected type (or its equatable); unfortunately, that is not setup (by Realm) - unless I am missing something.
I supplied the Xcode help info for the method above (labeled: "Xcode Code (help) Summary for"). This is not a run-time error but a compile error. The parameter wants a 'URL
' type argument to be passed - though (my opine) it should be a 'String
' type since Realm v10+ uses Partitions. Anyhow, this worked before Realm v10 (of course diff syntax: '.session(for: realmURL)
'). I looked for other alternatives to get a session through a partition - no luck. If it matters, I want to get a progress notifier on a partition, which is via a session. FYI - there is still a way to get a progress notifier via a Realm's '.syncSession
' ... I just wanted to report this for an exposed method not working.
'realmURL
' is a URL type in Swift (again I think it should be a 'String
' [or at least make it overloaded])
You could try to place this code into a Realm-Swift Xcode project:
let realmURL = URL(string: "ANY-REALM-PATH")!
let session = myApp.currentUser!.session(forPartitionValue: realmURL)
... let me know if there is something more specific I can provide
The documentation for this function is out of date. The argument is the partition value you used to open the Realm which you want the session for, and not a URL.
Hi @tgoyne,
okay I figured docs being bad was part of the problem. Though, the Partition value supplied upon creating a Realm is of 'String' type, this method doesn't take a 'String' (as I mentioned above) - hence my mention correcting its equatable. Additionally, I could not find a way to get a 'RLMBSON' value for the Partition from the Realm, to supply it as the argument either. Please let me know if I am missing something else ... again just reporting what I see (could be) a minor bug to correct.
If you have a Realm instance already you should just get the sync session via realm.syncSession
.
@tygone Yup, I know that - as I wrote that above too (the "FYI" to DominicFrei) ... so just reporting this if it matters.
Thanks for clarifying on both sides! I have updated the title of the issue and will keep it open for the necessary documentation change. 👍
Hi @DominicFrei - welcome & thanks!
Though, it is more than a doc issue, since the type required isn't available. So unless I am missing something - I see one of the three ways to correct this: 1) remove the method and only allow a 'session' via 'realm.syncSession', 2) allow the method to take a 'String' argument, or 3) update 'RLMBSON' to be created with 'String' type
... I hope that helps
App appears to be missing a Swift wrapper for that function so the obj-c version is exposed instead.
hey @tgoyne - cool, you found it!
... have a good one!
Goals
pass a URL argument to 'forPartitionValue:' parameter for '.session(forPartitionValue:)'
Expected Results
pass URL (or some other type) and get a session returned, on that realmURL
Actual Results
getting type-syntax error since URL is not equatable to 'RLMBSON' ERROR: "Argument type 'URL' does not conform to expected type 'RLMBSON'"
Steps for others to Reproduce
upon writing code:
myApp.currentUser!.session(forPartitionValue: realmURL)
-- I've tried a 'String' too. -- Also, cannot type cast to RLMBSON (nor BSON) - it seems at to be a equatable issueCode Sample
myApp.currentUser!.session(forPartitionValue: realmURL)
Xcode Code (help) Summary for '.session(forPartitionValue:)': ----------------------------------------- -- Summary -- Retrieve a valid session object belonging to this user for a given URL, or
nil
if no such object exists. ---- Declaration -- func session(forPartitionValue partitionValue: RLMBSON) -> RLMSyncSession? --
-- Parameters -- partitionValue | No description. -----------------------------------------
Version of Realm and Tooling
Realm Swift 10.7.2 Xcode 11.7