Giter Site home page Giter Site logo

rbqfetchedresultscontroller's People

Contributors

anlaital avatar ataibarkai avatar bigfish24 avatar codeisjoy avatar cvermilion avatar edowling avatar hanief avatar jamesonreed avatar mhollisfb avatar mrchristopher124 avatar ngs avatar phatblat avatar segiddins avatar virl avatar yuuki1224 avatar zenghaojim33 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rbqfetchedresultscontroller's Issues

Uncaught exception 'RLMException', reason: 'Path '(null)' is not valid

Hello, i'm facing an issue with the RBQFetchedResultsController it crashes systematically...
the crash log : crashlog.txt

Turns out to be a "RBQSafeObject" that has no "realm" attached and no "realmConfiguration".
I'm using realm 0.95.3.

Here is the code i used to instantiate the controller :

    @try {
        id <AppServices> service  = self.viewModel.services;
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"userId == %@",service.userService.userID];

        RBQFetchRequest *fetchRequest = [RBQFetchRequest fetchRequestWithEntityName:@"Photo"
                                                                            inRealm:[RLMRealm defaultRealm]
                                                                          predicate:predicate];



        RLMSortDescriptor *sortDescriptor = [RLMSortDescriptor sortDescriptorWithProperty:@"creationTime"
                                                                                ascending:NO];



        fetchRequest.sortDescriptors = @[sortDescriptor];

        self.fetchedResultsController = [[RBQFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                                                               sectionNameKeyPath:nil
                                                                                        cacheName:@"YoobiMyPhotoFetchRC"];

        self.fetchedResultsController.delegate = self;

        [self.fetchedResultsController performFetch];
    }
    @catch (NSException *exception) {
        LOG_ERROR(0,@"Error with RBQFetch exception : %@",exception);
    }

I'm trying to fix it in a fork but not finding the right way...
ANy help would be much appreciated :)

Bye!

Cache is empty

I was wondering if someone has experienced this problem where despite creating a cache successfully, the cache itself is empty. This makes it impossible to return items using objectAtIndex:

Assertion failure "Cache can't be nil"

Occassionally, this assertion fails. I would be able to pull out my data from the cache, then the next second, this assertion fails. I just verified (since I crashed while using the simulator) that the cache folder is not empty. I am unable to reliably reproduce this. Could you provide some insight as to what could be causing this assertion to fail?

Best practice for multi-users with encrypted realm FRC cache

I'm currently using your FRC in a platform that supports multiple users. Encryption is also turned on for realm. I noticed that if I logged out, and tried to log in as a different user, an exception stating the wrong encryption key is being used to open the cache. I tried calling deleteCacheWithName and passing in nil to delete everything, but then another exception:

Terminating app due to uncaught exception 'RLMException', reason: 'Realm at path '/Users/jasperchan/Library/Developer/CoreSimulator/Devices/60242241-EB72-4C8C-A7DA-8D017E03F860/data/Containers/Data/Application/540996A9-147F-4AAC-B9CA-EB03A50B4AE5/Documents/RBQFetchedResultsControllerCache/sceneFileCache/sceneFileCache.realm' already opened with different encryption key'

I was hoping if you could provide the best practice using this FRC to resolve this issue. Thanks

RBQFetchedResultsController should be able to be used with a realm with a custom path

Is there a reason that RBQFetchedResultsController doesn't allow injection of a realm path instead of generating it's own from cache names? Since I have another class that manages the creation of a realm with a custom path and dealing with realm transactions this would be a helpful way to initialize an instance of RBQFetchedResultsController. Would adding this initializer cause any issues with how the class is currently implemented? Thanks for the insight in advance!

Using a different KeyPath to group results

From what I understand RBQFRC uses sectionNameKeyPath in the initialiser to group results by that key path.

In my use case, and perhaps it's a (iffy) corner case, I need to group results via another key path that is not the same as the sectionName.

I'm not sure I am explaining myself correctly.

ClassName with Swift Frameworks

I'm pulling Realm and RBQFetchedResultsController into our swift app that uses a bunch of in-house frameworks. In particular we have a RLMObject that we call RealmCourse that lives in the Swift framework CourseKit. Thus for namespacing, the correct class name is "CourseKit.RealmCourse". However when this gets put through:+ (NSString *)classNameForObject:(RLMObject *)object the className gets set to "Courses.RealmCourse", where "Courses" is the name of our app, as opposed to the framework the RealmCourse actually lives in. This causes our fetched results controller to always return nil because of the improper naming. I was able to fix it on our side by simply adding a category on RBQObjectCacheObject:

#import "RBQObjectCacheObject+SwiftFrameworkNaming.h"

@implementation RBQObjectCacheObject (SwiftFrameworkNaming)

+ (instancetype)createCacheObjectWithObject:(RLMObject *)object
                        sectionKeyPathValue:(NSString *)sectionValue
                                  className:(NSString *)className
{

    RBQObjectCacheObject *cacheObject = [RBQObjectCacheObject createCacheObjectWithObject:object sectionKeyPathValue:sectionValue];
    cacheObject.className = className;

    return cacheObject;
}

@end

And in RBQFetchedResultsController I changed createCacheWithRealm:cacheName:forFetchRequest:sectionNameKeyPath: to call my new category method:

            RBQObjectCacheObject *cacheObject = [RBQObjectCacheObject createCacheObjectWithObject:object
                                                                              sectionKeyPathValue:currentSectionTitle
                                                                                        className:fetchRequest.entityName];

So just an fyi. It's working for me with my little fix.

Upon RLMObject mutation, UI gets blocked completely

hi @bigfish24 ,
Currently i'm using RBQFetchedResultsController in a project, all went smoothly except one issue i have right now, in one viewController i have contains a tableView which shows too many objects ( 250+ ) and those objects are fetched via RBQFRC , now when i modify an object to mark as favorite, i get the whole UI freezing for ~3 second and then becomes responsive again, i'm using:

RLMRealm *rlm = [RLMRealm defaultRealm];
[rlm beginWriteTransaction];
[objectToFavorite changeWithNotification:^(ObjectSubclass *__object){
         __object.favorite = !__object.favorite;
}];
[rlm commitWriteTransaction];

Freeze time increases as number of objects go up, so any suggestion how to avoid blocking the UI ?
Thank you

Handling 1-N update Notifications

Firstly, thanks for providing this solution, it enabled me to finally make the switch over to realm, and so far the transition has been night and day as far as performance and complexity (reduction) is concerned.
I've been trying to find the best way to notify my TableViewController which contains an RBQFetchedResultsController. The issue I am having is with tracking changes to my one-to-many relationship.

For example:

@interface ClassA : RLMObject
@property NSString *objectId; // Primary Key
@property RLMArray <ClassB *><ClassB> *children;
...
@end

@interface ClassB : RLMObject
@property NSString *objectId;  // Primary Key
...
@end

RLM_ARRAY_TYPE(ClassB)

I have a thread that keeps our data in sync with our backend and as such I use a typical import:

RLMRealm *realm = [RLMRealm defaultRealm];

[realm beginWriteTransaction];

for (NSDictionary *response in responses)
{
    NSString *primaryKey = ...;

    ClassA *parent = [ClassA objectForPrimaryKey:primaryKey];

    if (!parent)
    {
        parent = [[ClassA alloc] init];
    }

    [parent importWithResponse:response];

    // Adding or updating child objects.

    NSInteger importCount = 0;

    for (NSDictionary *childResponse in [response objectForKey:@"children"])
    {
        importCount++;

        NSString *childPrimaryKey = ...;

        ClassB *child = [ClassB objectForPrimaryKey:childPrimaryKey];

        // This is where I'm missing something, but I generally do the following:

        if (!child)
        {
            child = [[ClassA alloc] init];
            [child importWithResponse:childResponse];
            [parent.children addObject:child];
        }
        else
        {
            [child importWithResponse:childResponse];
        }

        if (importCount % IDEAL_IMPORT_COUNT == 0)
        {
            [realm commitWriteTransaction];
            [realm beginWriteTransaction];
        }
    }

    [realm addOrUpdateObjectWithNotification:parent]; 
}
[realm commitWriteTransaction];

Whenever I am in the TableView that fetches ClassB object(s) its never notified of any changes, this is particularly due to the fact that I am not using the notification methods within RLMRealm+Notifications.h.

I've tried various ways of adding ClassB objects using [realm addOrUpdateObjectWithNotification:...]; and then attempting to add it to ClassA, but this results in a throw.

Currently, the setup I have uses a RLMNotificationToken which causes my fetchedResultsController to update, whenever there is a didChangeNotification, this isn't ideal as any changes to the realm which may not particularly correlate to ClassA.children are invoked and cause the fetchResultsController to inefficiently refetch data. I understand that this is a current limitation because of the lacking fine grain notifications from realm, and I do understand that I can roll my own notifications. Is there something that I am missing in how I am importing my one-to-many relationship to benefit from notifications, without using my current setup?

Comparator for section titles

I would like to use a custom comparator for section titles.

I know it has a drawback in performance with Realm.

But Alphabetical order is not "good" enough for my case.

I need to push "#" to the end, after the normal letters.

Is that possible?

RBQFetchedResults controller is returning nil

Hi,

I am experiencing an issue, where the FRC is returning nil when calling objectAtIndexPath:

I reproduce this when sending a new item to Realm and notifying the FRC and at the same time scrolling a collection view.

I think it is related to querying realm in the main thread which is doing a lot of UI work, which causes realm to return nil. This is prolly a realm problem though.

realm/realm-swift#2795

Problem with Realm 0.91.2 or later

After I update realm to 0.91.2, it will crash with Safe object can't be nil! message.
But if I force realm to 0.91.1, it work fine ๐Ÿ˜–.

RBQRealmChangeLogger didAddObjects doesn't trigger FRC update

I don't know if this is a bug or some mis-configuration of my project, but the thing is: updates/deletes are always propagated to the FRC, but creates don't.

Sample:
[[RBQRealmChangeLogger defaultLogger] didAddObjects:createdObjects];

I have breakpoints on the following callbacks but not a single one is fired for a create action (only for update/delete):

- (void)controllerWillChangeContent:(RBQFetchedResultsController *)controller;
- (void)controller:(RBQFetchedResultsController *)controller
   didChangeObject:(RBQSafeRealmObject *)anObject
       atIndexPath:(NSIndexPath *)indexPath
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath;
- (void)controller:(RBQFetchedResultsController *)controller
  didChangeSection:(RBQFetchedResultsSectionInfo *)sectionInfo
           atIndex:(NSUInteger)sectionIndex
     forChangeType:(NSFetchedResultsChangeType)type;
- (void)controllerDidChangeContent:(RBQFetchedResultsController *)controller;

I'm using release 2.2 and Realm 0.95.3

Sectioning support for NSDate

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[**NSTaggedDate isEqualToString:]: unrecognized selector sent to instance 0xe41bc46f25000000'
* First throw call stack:
(
0 CoreFoundation 0x000000010a2cfe65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000109927deb objc_exception_throw + 48
2 CoreFoundation 0x000000010a2d848d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010a22590a __forwarding
+ 970
4 CoreFoundation 0x000000010a2254b8 _CF_forwarding_prep_0 + 120
5 FoilChat 0x0000000105cd4e31 -[RBQFetchedResultsController createCacheWithRealm:cacheName:forFetchRequest:sectionNameKeyPath:] + 1345
6 FoilChat 0x0000000105ccf5eb -[RBQFetchedResultsController performFetch] + 587
7 FoilChat 0x0000000105bd309b -[FCChatDataSource initWithCollectionView:forChat:] + 1051
8 FoilChat 0x0000000105c1e8b4 -[FCChatViewController viewDidLoad] + 724
9 UIKit 0x0000000107c95f98 -[UIViewController loadViewIfRequired] + 1198
10 UIKit 0x0000000107c9bf4f -[UIViewController __viewWillAppear:] + 120
11 UIKit 0x0000000107ccbe44 -[UINavigationController _startCustomTransition:] + 1203
12 UIKit 0x0000000107cdc23f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
13 UIKit 0x0000000107cdd3af -[UINavigationController __viewWillLayoutSubviews] + 57
14 UIKit 0x0000000107e83ff7 -[UILayoutContainerView layoutSubviews] + 248
15 UIKit 0x0000000107bb64a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
16 QuartzCore 0x000000010788059a -[CALayer layoutSublayers] + 146
17 QuartzCore 0x0000000107874e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
18 QuartzCore 0x0000000107874cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000107869475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
20 QuartzCore 0x0000000107896c0a _ZN2CA11Transaction6commitEv + 486
21 UIKit 0x0000000107b2ab47 _afterCACommitHandler + 174
22 CoreFoundation 0x000000010a1fb367 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
23 CoreFoundation 0x000000010a1fb2d7 __CFRunLoopDoObservers + 391
24 CoreFoundation 0x000000010a1f0f2b __CFRunLoopRun + 1147
25 CoreFoundation 0x000000010a1f0828 CFRunLoopRunSpecific + 488
26 GraphicsServices 0x000000010c9b1ad2 GSEventRunModal + 161
27 UIKit 0x0000000107aff610 UIApplicationMain + 171
28 FoilChat 0x0000000105be653f main + 111
29 libdyld.dylib 0x000000010aad992d start + 1
)

I have this one when I try to group datasource by NSDate. I have property "date" (NSDate type) and i setup it to sectionNameKeyPath like @"date".

Why do you compare NSString in this lines
.....
if (sectionNameKeyPath) {

            // Check your sectionNameKeyPath if a crash occurs...
            NSString *sectionTitle = [object valueForKeyPath:sectionNameKeyPath];

            // New Section Found --> Process It
            if (![sectionTitle isEqualToString:currentSectionTitle]) {

....

Project Architecture

I think, for now it's difficult to contribute RBQFetchedResultsController itself because it doesn't show in Xcode navigation when I open RBQFetchedResultsControllerExample.xcworkspace (just show Pods/RBQFetchedResultsController)

So maybe option to solve this problem are
RBQFetchedResultsController from Podfile in example project and Example project includes the source code of RBQFetchedResultsController.
or
Create RBQFetchedResultsController library target.

What do you think? @bigfish24

Duplicate interface definition for class 'RLMObjectSchema'

I am trying to use this library in my swift project, and am not able to build due to duplicate interface definition error. Any ideas ?

#Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

use_frameworks!
pod 'RBQFetchedResultsController'

screen shot 2015-04-19 at 6 04 46 pm

Cant create RBQFetchRequest with nil predicate.

When i create RBQFetchRequest with nil predicate and create new object with addOrUpdateObjectWithNotification,it not notify change and then I try to dig to the code and found that in evaluateObject if predicate are nil it will alway return false.

Is this bug or i missing something.
Sorry for my bad english.

Compile error after pod installed

clang: error: no such file or directory: '/Users/pro/Downloads/RBQFetchedResultsController-master-2/RBQFetchedResultsController/RealmUtilities/RLMArray+Utilities.m'
clang: error: no input files

any solution?

KVO for Automatic Change Reporting?

I see that you added a KVO branch to KVO List properties, but there may be another use that could allow you to automatically report changes. If, whenever an object was added or updated through the addWithNotification: method, you called objectSchema on the object and retrieved the property names from that, you could observe changes to all properties of every object - automatically. You could then stop observing when the object it is deleted.

This could potentially allow the elimination of the need for manual change reporting.

Unable to compile RBQFetchResultController with

Has anyone encountered the error "Multiple methods named 'hash' found with mismatched set, parameter type or attributes" in the RBQSafeRealmObject.m file? I've had to comment out the function

(NSUInteger)hash
{
    return [_primaryKeyValue hash];
}

to get the code to compile

addOrUpdateObjectWithNotification: detecting updates as additions?

- (void)addOrUpdateObjectWithNotification:(RLMObject *)object seems to treat objects that are not from the same realm as additions otherwise it will treat them as updates. Shouldn't it also be an update if an record with that primary key also exists in the realm for the RLMObject subclass and the instance passed in is not yet attached to a realm? Realm will do an update in this case but I get a notification that it is an insert.

Framework wants to load Swift but I use ObjC

Hey guys I'm really loosing my mind here.

I installed Realm itself and that worked, then wanted to use this resultsController and its impossible for me to get this working. I tried installing it via Carthage with instructions how to install Frameworks from the Carthage site, from this github page everything. I just dont get it.

I always get:

dyld: Library not loaded: @rpath/RealmSwift.framework/RealmSwift
  Referenced from: /Users/xyz/Library/Developer/CoreSimulator/Devices/3BF0D5DD-53D8-4996-A575-0D5D9F960DD7/data/Containers/Bundle/Application/0E868ED2-F66C-429A-99BD-F2D5DB7C7226/xyz.app/Frameworks/RBQFetchedResultsController.framework/RBQFetchedResultsController
  Reason: image not found
(lldb) 

Why is RealmSwift.framework referenced? I installed Realm ObjC form their website. And I put like you can see RBQFetchedResultsController in my project and not SwiftFetchedResultsController.

While it makes no sense, I added the ReamSwift.framework too but that doesnt end well because well its no swift project.

Any tips how to get this working?
When Carthage is getting the resultsController its also downloading Realm.framework. Should I use this version? Or whats up with that.

Thanks guys
I hate those linking errors...

[Question] Reusing FetchedResultsController in multiple ViewControllers?

Hi guys,

because of not having fine-grained notifications in Realm I found this nice project. Thank you very much for your work :)
In my project I need to achieve that multiple ViewControllers getting notified if Task entities added/removed/changed.
For example a Task in UITableViewControllerA was added then UITableViewControllerB and UICollectionViewControllerA will be notified about that new Task object.
So I thought I could create a class which stores the FetchedRequestsController and forwarding delegate methods to every ViewController, acting as a Data Manager class.

It works that data will be rendered in ViewControllers as expected and FetchedResultsControllerDelegate will be forwarded by the data manager, but if I want to add a new Task entity for example the SafeObject is only valid in one (random) delegate call.

Is this somehow possible to reuse FetchedResultsController or is it impossible and I should implement FetchedResultsController for every ViewController?

Thanks in advance!

Alex

Here is a simplified example:

class TaskDataManager: NSObject {

    lazy var items: Results<Task>? = {
        guard let fetchedResultsController = self.fetchedResultsController else {
            return nil
        }
        return fetchedResultsController.fetchedObjects
    }()

    var delegate: TaskDataManagerDelegate?

    var fetchedResultsController: FetchedResultsController<Task>?

    private var realm = try! Realm()

    var changingOrder = false

    override init() {
        super.init()

        let fetchRequest = FetchRequest<Task>(realm: self.realm, predicate: NSPredicate(format: "id > 0"))
        let sortDescriptor = SortDescriptor(property: "displayOrder", ascending: true)
        fetchRequest.sortDescriptors = [sortDescriptor]
        self.fetchedResultsController = FetchedResultsController<Task>(fetchRequest: fetchRequest, sectionNameKeyPath: nil, cacheName: "tasksCache")
        self.fetchedResultsController!.performFetch()

        self.fetchedResultsController!.delegate = self
    }

    func deleteTask(task: Task) {
        try! realm.write {
            realm.deleteWithNotification(task)
        }
    }

    func createTask(task: Task) {
        try! realm.write {
            realm.addWithNotification(task, update: true)
        }
    }
}

// MARK: - FetchedResultsControllerDelegate
extension TaskDataManager: FetchedResultsControllerDelegate {
    func controllerWillChangeContent<T: Object>(controller: FetchedResultsController<T>) {
        delegate?.dataManagerWillChangeContent?(self)
    }

    func controllerDidChangeObject<T: Object>(controller: FetchedResultsController<T>, anObject: SafeObject<T>, indexPath: NSIndexPath?, changeType: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
        delegate?.dataManager(self, didChangeTask: anObject.object() as? Task, fromIndexPath: indexPath, toIndexPath: newIndexPath, changeType: changeType)
    }

    func controllerDidChangeSection<T:Object>(controller: FetchedResultsController<T>, section: FetchResultsSectionInfo<T>, sectionIndex: UInt, changeType: NSFetchedResultsChangeType) {
    }

    func controllerDidChangeContent<T: Object>(controller: FetchedResultsController<T>) {
        delegate?.dataManagerDidChangeContent?(self)
    }
}

// MARK: - taskDataManagerDelegate Protocol
@objc protocol TaskDataManagerDelegate {
    optional func dataManagerWillChangeContent(dataManager: TaskDataManager)
    optional func dataManagerDidChangeContent(dataManager: TaskDataManager)
    func dataManager(dataManager: TaskDataManager, didChangeTask object: Task?, fromIndexPath: NSIndexPath?, toIndexPath: NSIndexPath?, changeType: NSFetchedResultsChangeType)
}

And then in a TableViewController:

class TaskTableViewController: UITableViewController {
    var taskDataManager: taksDataManager!

    override func viewDidLoad() {
                super.viewDidLoad()
        taskDataManager = TaskDataManager()
        taskDataManager.delegate = self
        ...
    }
    ...

    func addNewTask() {
        ...
        // This notificates all delegates attached to TaskDataManager
        taskDataManager.create(task)
    }   
}

extension TaskTableViewController: TaskDataManagerDelegate {
 func dataManagerWillChangeContent(dataManager: TaskDataManager) {
        tableView.beginUpdates()
    }

    func dataManager(dataManager: TaskDataManager, didChangeTask task: Task?, fromIndexPath: NSIndexPath?, toIndexPath: NSIndexPath?, changeType: NSFetchedResultsChangeType) {
       switch changeType {
        case .Insert:
            tableView.insertRowsAtIndexPaths([toIndexPath!], withRowAnimation: .Fade)
            break
        case .Update:
            break
        case .Delete:
            tableView.deleteRowsAtIndexPaths([fromIndexPath!], withRowAnimation: .Fade)
            break
        case .Move:
            tableView.deleteRowsAtIndexPaths([fromIndexPath!], withRowAnimation: .Fade)
            tableView.insertRowsAtIndexPaths([toIndexPath!], withRowAnimation: .Fade)
            break
        }
    }

    func dataManagerDidChangeContent(dataManager: TaskDataManager) {
        tableView.endUpdates()
    }

}

support for Realm Swift (with Object as the base model class instead of RLMObject)

Hey there
It seems that the examples and RBQFetchRequest are dependent upon using Realm's Objective-C framework, where RLMObject is the base class for model classes, whereas in Realm for Swift, the base class is simply Object. (I get assertion failures for example when trying to use Object).

I'm happy to work on this, but before I dive in, would anybody be able to offer any guidance about what specifically would need to be done to be as non-invasive as possible? Is this already in the works?

Thank you

Swift 2.0

Realm currently has a RelamSwift Swift 2.0 branch that allows building using Xcode 7 and Swift 2.0. Have you thought about a similar setup? Unfortunately using that Realm branch and the current SwiftFetchedResultsController does not work, as there are build errors.

delegate doesn't seem to respond

I'm currently struggling to integrate FBQFetchedResultsController into my project. The FRC fetches, but it doesn't dynamically update itself to show the new information because the delegates aren't being called. I did set the FRC's delegate to my view controller. I'm not sure what else I could be missing... Has anyone else run into this problem?

Object state not in sync in controllerDidChangeObject

Hi,

I'm getting all the necessary notifications for updated objects in controllerDidChangeObject, but the updated property of the object is not in sync with what was written on my serial dispatch queue (for database operations).

If I do a try! Realm().refresh() in controllerDidChangeObject -- e.g. whenever the change type is Updated -- the problem goes away.

I might add that the same property is written to twice in quick succession in different tasks on the same serial queue, and that in controllerDidChangeObject the second write appears as if it were the first write. I currently keep strong references to all the realm objects in the FRC and I'm assuming they will be up-to-date in controllerDidChangeObject.

Invalid Value for Primary Key

I keep running into errors when attempting to call updateFetchRequest. It works fine when it is called once, but while switching through my data's different states via predicates, it gives me the following stack trace:

2015-05-28 21:27:45.534 app[92238:28255111] *** Terminating app due to uncaught exception 'RLMException', reason: 'Invalid value '96356644' for primary key'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ee42c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000111929bb7 objc_exception_throw + 45
    2   Realm                               0x000000010e576385 RLMGetObject + 1093
    3   Realm                               0x000000010e5640d8 +[RLMObject objectInRealm:forPrimaryKey:] + 136
    4   RBQFetchedResultsController         0x000000010e5103c0 -[RBQFetchedResultsController createChangeSetsWithAddedSafeObjects:deletedSafeObjects:changedSafeObjects:state:] + 2352
    5   RBQFetchedResultsController         0x000000010e50c07d -[RBQFetchedResultsController calculateChangesWithAddedSafeObjects:deletedSafeObjects:changedSafeObjects:realm:] + 2173
    6   RBQFetchedResultsController         0x000000010e50aed8 __58-[RBQFetchedResultsController registerChangeNotifications]_block_invoke + 1208
    7   RBQFetchedResultsController         0x000000010e51d406 -[RBQRealmNotificationManager sendNotificationsWithRealm:entityChanges:] + 518
    8   RBQFetchedResultsController         0x000000010e51f660 __50-[RBQRealmChangeLogger registerChangeNotification]_block_invoke + 256
    9   Realm                               0x000000010e5bd58a -[RLMRealm sendNotifications:] + 986
    10  Realm                               0x000000010e5bd9c6 -[RLMRealm commitWriteTransaction] + 262
    11  app                          0x000000010e092a3c _TZFC105pp5Shift13fromJSONArrayfMS0_FPSs9AnyObject_GSaS0__ + 1964
    12  app                          0x000000010e05dc3b _TFFC10app17CalendarViewModel15invokeShiftListFS0_FTGSqGVSs10DictionarySSPSs9AnyObject___10completionFT_T__T_U_FTGSQCSo22AFHTTPRequestOperation_GSQPS2____T_ + 331
    13  app                          0x000000010df8fdb3 _TTRXFo_oGSQCSo22AFHTTPRequestOperation_oGSQPSs9AnyObject___dT__XFo_iTGSQS__GSQPS0_____iT__ + 35
    14  app                          0x000000010e05bbd1 _TPA__TTRXFo_oGSQCSo22AFHTTPRequestOperation_oGSQPSs9AnyObject___dT__XFo_iTGSQS__GSQPS0_____iT__ + 81
    15  app                          0x000000010e02a097 _TTRXFo_iTGSQCSo22AFHTTPRequestOperation_GSQPSs9AnyObject____iT__XFo_oGSQS__oGSQPS0____dT__ + 39
    16  app                          0x000000010e02a0e9 _TTRXFo_oGSQCSo22AFHTTPRequestOperation_oGSQPSs9AnyObject___dT__XFdCb_dGSQS__dGSQPS0____dT__ + 73
    17  SBJSONRPCClient                     0x000000010e858067 __67-[SBJSONRPCClient HTTPRequestOperationWithRequest:success:failure:]_block_invoke + 471
    18  AFNetworking                        0x000000010e3f6b48 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke46 + 40
    19  libdispatch.dylib                   0x0000000111c80186 _dispatch_call_block_and_release + 12
    20  libdispatch.dylib                   0x0000000111c9f614 _dispatch_client_callout + 8
    21  libdispatch.dylib                   0x0000000111c87a1c _dispatch_main_queue_callback_4CF + 1664
    22  CoreFoundation                      0x000000010edaa1f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    23  CoreFoundation                      0x000000010ed6bdcb __CFRunLoopRun + 2043
    24  CoreFoundation                      0x000000010ed6b366 CFRunLoopRunSpecific + 470
    25  GraphicsServices                    0x0000000114333a3e GSEventRunModal + 161
    26  UIKit                               0x000000010ffaf900 UIApplicationMain + 1282
    27  app                          0x000000010e057d27 main + 135
    28  libdyld.dylib                       0x0000000111cd3145 start + 1
)

I can successfully switch once to a different fetchRequest without crashing. Any more times crashes the app. It also doesn't happen on the same primary key, it's random.

`- (id)objectInRealm:atIndexPath:` is needed?

This method is needed?
https://github.com/Roobiq/RBQFetchedResultsController/blob/master/RBQFetchedResultsController/RBQFetchedResultsController.h#L265

My thought is that RBQFetchedResultsController and RBQFetchedRequest is always 1 to 1. So RBQFetchedRequest can specify Realm path. I think RBQFetchedResultsController has always specify one Realm path.

And just curious if it will be passed another Realm that is different with the Realm path that RBQFetchedRequest has, what will it be?

If this is needed with some reason, sorry and close this issue.

Inserting new sections fails on iOS9 (iOS8 works fine)

2015-10-17 22:48:15.744 Stellup[94318:24976924] Inserting section at 0
2015-10-17 22:48:15.745 Stellup[94318:24976924] Inserting section at 1
2015-10-17 22:48:15.745 Stellup[94318:24976924] Inserting section at 2
2015-10-17 22:48:15.747 Stellup[94318:24983296] 3 Derived Inserted Sections
2015-10-17 22:48:15.748 Stellup[94318:24983296] 0 Derived Deleted Sections

RBQFecthResultsTVC caught exception updating table view: Invalid update: invalid number of sections. The number of sections contained in the table view after the update (3) must be equal to the number of sections contained in the table view before the update (0), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).. Falling back to reload.

Helper function for sectionForSectionName

Hi,

Thanks for your hard work on this project. It's been a great alternative to NSFetchedResultsController. I was wondering if there was anything on the roadmap for adding a sectionForSectionName helper function?

Support Realm 0.98's fine grained notifications in some way

This is more likely a doubt than an issue. So please tag it accordingly.

I don't know if this makes sense but, is there any improve if we use the new Collection Notifications from Realm's 0.98?
I'm just asking you that you have the know-how about this codebase so is it worth trying to use those notifications?

Thanks

Occasionally getting wrongfully deleted objectNotifications

We have a collection view to display RLMObjects.
It's a basic chat view, where the messages are the RLMObjects.

Due to some issues with how collections views react to many UI updates we have implemented something like this: https://github.com/radianttap/UICollectionView-NSFetchedResultsController

However we are receiving wrong notifications from the FRC. Saying we either inserted / deleted sections / items. And in some cases it causes internal inconsistencies with the collections view.

Have you seen this happening before?

Fatal Exception: NSInternalInconsistencyException
Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (1) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted). 

EDIT: I forgot to say, that in this view we have only 1 section, and we never delete objects.

Cell reordering not working via `canMoveRowAtIndexPath:`

Hi guys, do you have any idea why cell reordering doesn't work after setting YES for editing mode on the tableview? Is it supported?

Thanks!

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

Memory Management issue

Hey,

I ran into a problem with memory management and using the FetchedResultsController. Below I've attached a class diagram showing how the classes are currently being constructed.

plantuml1734893313714000776

Looking at the diagram there is a retain cycle between the delegate proxy and the FetchedResultsController and one between the FetchedResultsController and my ViewController. This is causing all the objects in this graph to not be cleaned up after they're pushed off the navigation stack. Basically when I comment out self.viewModel.fetchResults.delegate = self all my classes get cleaned up.

I have been digging in the code and found that if changing the protocols to extend :class and change both delegate refs in DelegateProxy and FetchedResultsController to weak public var delegate: <Type>? all the objects get cleaned.

If I'm doing something wrong please let me know otherwise I can fork the code and make the changes if you feel this change is appropriate.

Thanks,
Mike.

Swift Example is almost working - except when clicking "Delete" which causesNSInvalidArgumentException

The exception happens when clicking the "Delete" button (in the upper left-hand corner) which causes an "'NSInvalidArgumentException', reason: '-[RLMResults isInvalidated]: unrecognized selector sent to instance 0x7fb8b31d1860'".

It looks like objectsWhere (TestObject.objectsWhere("%K == %@","sectionName","First Section")) is handled differently in the Realm-provided RLMSupport.swift and as a result, the results are invalidated...

I updated the swift example pull request.

Primary key in cache objects set to invalid value

Hi.

I think primaryKeyStringValue of RBQObjectCacheObject is set to an invalid value when the primary key is of type NSInteger. FRC returns correct number of sections and rows but method [RBQFRC objectInRealm:atIndexPath:] always returns nil.

When replacing following code (line 30) in file 'RBQObjectCacheObject.m':
cacheObject.primaryKeyStringValue = @((NSInteger)primaryKeyValue).stringValue;
with:
cacheObject.primaryKeyStringValue = ((NSNumber *)primaryKeyValue).stringValue;
It works as it should

Seems like "[RLMObject primaryKeyValueForObject:];" returns an NSNumber* not an NSInteger.

Realm 0.97 throws if notification block is added on thread without runloop

RBQRealmNotificationManager, should be refactored to use a singleton worker thread that will receive the Realm notifications and pass along changes to RBQFetchedResultsController so that the dev never has to worry about passing changes to RBQRealmNotificationManager on a background queue/thread that doesn't have a runloop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.