Closed tuomijal closed 7 years ago
Hi @EmilOsvald. Thanks for reaching out about this. My apologies for the delay in getting back to you. I'll have one of the engineers look at this and follow-up with a solution or additional questions.
There's nothing particularly suspicious in the code you've posted. If you're willing to share the full project I'd be happy to dig into it, as the function that's throwing is something that shouldn't be able to fail.
Hi @tgoyne, thank you for your input and sorry for the delay. I cleared the decks and everything works in my refactored project like a charm. I suppose the problem was that I had done some rookie mistake in my code (as I had suspected). Would you nevertheless like to see the original version?
Yes, that'd still be helpful. Even if you did only hit problems due to a mistake on your end, you still hit a case where Realm isn't behaving properly and it'd be good to be able to fix that.
Hey @EmilOsvald! Just checking in on this issue. Would you be able to provide us with a copy of the original version of your project for us to analyse? Thanks a lot!
Hi @TimOliver. I went through all my previous app versions on Git but unfortunately the version of interest seems to be lost. I am sorry.
@EmilOsvald Ahh okay. No problems then! It can't be helped. If you do manage to find the issue again, please let us know! Thanks!
I know this issues quite old and probably not interesting anymore, I was struggling however with the same problem for quite a while now and I'd like to share my findings. In my case it happened after a bulk delete. Whenever a user does a logout I have to clear some of my tables
- (void)deleteSecureContent:(RLMRealm *)realm {
NSError *error;
NSArray *array = [realm.schema.objectSchema valueForKey:@"className"];
[realm transactionWithBlock:^{
for(NSString *className in array){
Class<VLProtectedEntity> realmClass = NSClassFromString(className);
if(realmClass && [[realmClass class] respondsToSelector:@selector(isProtectedEntity)]){
BOOL protected = [[realmClass class] isProtectedEntity];
if(protected){
[realm deleteObjects:[[realmClass class] allObjectsInRealm:realm]];
}
}
}
} error: &error];
[realm refresh];
if (error) {
DDLogError(@"error %@ deleteSecureContent",error);
[[Crashlytics sharedInstance] recordError:error];
}
}
This is already the working version of the code. The important row in this case was the call to refresh the realm. Without that I had exactly the same error. It's probably important to say that I'm working with two realms in this project one is persistent and one is in-memory and only the latter, so the in-memory instance did suffer from this problem.
I'm on Realm (3.18.0)
Goals
I am trying to instantiate a NotificationToken to listen to changes in a specific property of my Realm objects. The goal is to display every object matching the query in viewController.
Expected Results
The variable called 'location' in my Realm objects is changed by a helper method which is triggered by a Timer instance. When 'location' property is changed to value 2, I expect the Realm to notify the notificationToken object about the change allowing me to push the new result to viewController.
Actual Results
Immediately after launching the app, addNotificationBlock method returns the following error:
Error Domain=io.realm Code=1 "std::exception" UserInfo={NSLocalizedDescription=std::exception, Error Code=1}
Notifications are not listened after this. (Which is of course the way this enumeration is supposed to work.) I opened a thread on StackOverflow and based on given instructions managed to setup a breakpoint which pointed to method calledvoid RealmCoordinator::pin_version(VersionID versionid)
Steps to Reproduce
It is difficult to say how to reproduce this error since I am (as far as I'm concerned) using the addNotificationBlock as instructed and not trying to accomplish anything complicated. I am happy to deliver the full Xcode workspace if necessary.
Code Sample
The contents of my viewController:
In addition I have a helper method in another file:
Thank you in advance.
Version of Realm and Tooling
Realm version: 2.4.2
Xcode version: 8.2.1
iOS/OSX version: 10.12.3
Dependency manager + version: Cocoapods 1.1.1