bigfish24 / abfrealmsearchviewcontroller Goto Github PK
View Code? Open in Web Editor NEWDrop-in text search interface for Realm data
License: MIT License
Drop-in text search interface for Realm data
License: MIT License
Environment information:
XCode 7.3.1
Realm 1.0.1
ABFRealmSearchViewController 2.1
Crash:
The crash occurs on line 251 of ABFRealmSearchViewController:
id object = [self.results objectAtIndex:indexPath.row];
Terminating app due to uncaught exception 'RLMException', reason: 'Index 1 is out of bounds (must be less than 1)'
*** First throw call stack:
(
0 CoreFoundation 0x0120e494 exceptionPreprocess + 180
1 libobjc.A.dylib 0x00cc6e02 objc_exception_throw + 50
2 realmTest 0x0025d8f6 _ZL10throwErrorP8NSString + 662
3 realmTest 0x0025a3c4 _ZL15translateErrorsIZ28-[RLMResults objectAtIndex:]E3$_3EDaOT_P8NSString + 116
4 realmTest 0x0025a345 -[RLMResults objectAtIndex:] + 69
5 realmTest 0x0007661d -[ABFRealmSearchViewController tableView:cellForRowAtIndexPath:] + 173
6 UIKit 0x01a41804 -[_UIFilteredDataSource tableView:cellForRowAtIndexPath:] + 102
7 UIKit 0x01733934 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 822
8 UIKit 0x01733a7d -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
9 UIKit 0x01703b32 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3347
10 UIKit 0x01722416 __29-[UITableView layoutSubviews]_block_invoke + 52
11 UIKit 0x0173d6cc -[UITableView _performWithCachedTraitCollection:] + 88
12 UIKit 0x017222eb -[UITableView layoutSubviews] + 214
13 UIKit 0x016783d4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00cdb059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0554a096 -[CALayer layoutSublayers] + 144
16 QuartzCore 0x0553d8b6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x0553d71a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18 QuartzCore 0x0552fee7 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19 QuartzCore 0x05564847 _ZN2CA11Transaction6commitEv + 561
20 QuartzCore 0x05565108 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
21 CoreFoundation 0x0112075e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 30
22 CoreFoundation 0x011206be __CFRunLoopDoObservers + 398
23 CoreFoundation 0x0111603c __CFRunLoopRun + 1340
24 CoreFoundation 0x01115846 CFRunLoopRunSpecific + 470
25 CoreFoundation 0x0111565b CFRunLoopRunInMode + 123
26 GraphicsServices 0x04919664 GSEventRunModal + 192
27 GraphicsServices 0x049194a1 GSEventRun + 104
28 UIKit 0x015a7eb9 UIApplicationMain + 160
29 realmTest 0x00074c8a main + 138
30 libdyld.dylib 0x02c0ea25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Description:
This happens when I type two characters into the searchbar. The first character correctly filters the tableview and shows me the filtered results. The second character I type in causes the crash.
I have an extremely simple test project set up which subclasses ABFRealmSearchViewController and implements the cellForObject method. I'm searching against the only entity in the database which has a single nsstring field "name"
Please let me know I can provide any more information that could be of help.
I have an interesting problem. Just implemented code using the RealmSearchViewController (swift). And what I'm finding is that the view controller only shows the first object in the data model. But when I select the search control and then press cancel all of the records will appear. So I don't have to actually search for anything --- just selecting it so it has the focus and then pressing cancel will do this.
Any idea why this might be happening? Here is the model that I'm using for the search:
import Foundation
import RealmSwift
class Contact: Object {
dynamic var id: Int = 0
dynamic var company: Company?
dynamic var lastname: String? = nil
dynamic var firstname = ""
dynamic var title: String? = nil
dynamic var email: String? = nil
dynamic var website: String? = nil
dynamic var notes: String? = nil
dynamic var picture: String? = nil
dynamic var acceptsPostcards: Bool = false
dynamic var attendsShowcases: Bool = false
dynamic var type: Int = 0
dynamic var metdate: NSDate? = nil
dynamic var favorite: Bool = false
dynamic var source: Int = -1
dynamic var source_id: Int = -1
dynamic var status = "N"
dynamic var external_id: Int = -1
let history = List<ContactHistory>()
let addresses = List<ContactAddress>()
override static func primaryKey() -> String? {
return "id"
}
func getNextKey() -> Int{
let realm = try! Realm()
let contact_id : Int? = realm.objects(Contact).max("id")
if(contact_id == nil){
return 1
}else{
return contact_id! + 1
}
}
}
And In the storyboard I've entered "Contact" for the Entity Name, "lastname" as the Search Property, Sort Ascending is ON. Nothing out of the ordinary there.
Hi, I want to override the searchPredicate function but I can't since it is private. I tried to override refreshSearchResults() since it is public but then I can't access searchQueue property, since it is private. Can you offer another solution? Thanks
I saw you have hard coded the UITableViewControllerDataSource method
open override func numberOfSections(in tableView: UITableView) -> Int { return 1 }
I'm trying to figure out how your Swift Demo works, i can get it to search in tittle, emoji, content...but i cant make it search for all 3 at once... what string i have to put to make that work? thankyou
Hello, please help me understand the following. From the RealmSwift documentation :
If you’re looking to use Realm from Objective‑C, or from mixed Objective‑C & Swift apps please see Realm Objective‑C instead.
The Realm Objective‑C and Realm Swift APIs are not interoperable and using them together is not supported.
ABFRealmSearchViewController uses internal RBQFetchedResultsController. As far as I understand, at least according to XCode, RBQFetchedResultsController is a bunch of objective-c files so it must use objective-c api.
Can you share your thoughts with me about this issue?
Thank you
Hi. I've updated Xcode to 8.0. I have a view, that is subclassing ABFRealmSearchViewController. When i want to open this view I'm getting a crash in viewDidLoad method at [super viewDidLoad];.
I've checked where the problem is, it crashes is in ABFRealmSearchViewController.m at line self.viewLoaded = YES; in viewDidLoad method.
Any ideas what's wrong?
when i load [super ViewDidLoad]
my App is Crashed plz help me.
How could I load realm db file not from json file?
I was trying to use base Predicate to eliminate old records from being searched. The predicate works. But TableView crashes with the following message.
PREDICATE: self.basePredicate = NSPredicate(format: "start >= %@", Date() as CVarArg)
CRASH MESSAGE:
reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (42) must be equal to the number of rows contained in that section before the update (30), plus or minus the number of rows inserted or deleted from that section (1 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
If I am not using the right procedure to restrict the records, please help.
Thank you.
Allow RealmSearchViewController to be used with read-only realms where people only want to search from a static database. I am submitting a pull request that adds this support via a simple readOnly
property on RealmSearchViewController.
Is there a way to access the underlying data struct of results objects?
For example, I want to implement a delete edit function using
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
I have indexPath but no array of objects to get the object for deletion.
What is the recommended way of doing this in ABFRealmSearchViewController?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.