realm

CocoaPods and Realm in Swift

荒凉一梦 提交于 2020-01-04 02:41:06
问题 Using Xcode-6.3.1, iOS-8.3 and MacOS-10.10.3, I am trying to use RealmSwift (0.92.3) and CocoaPods 0.37.1 I use the following procedure : install cocoapods (in terminal): $ sudo gem install cocoapods Create new Xcode project (named MyApp) Create Podfile platform :ios, '8.3' use_frameworks! target 'MyApp' do pod 'RealmSwift', '>= 0.92.3' end target 'MyAppTests' do pod 'RealmSwift', '>= 0.92.3' end Place the Podfile in the MyApp folder (next to MyApp.xcodeproj) Download the newest Realm (0.92.3

How to save an array to a Realm Object

我与影子孤独终老i 提交于 2020-01-03 20:11:31
问题 I am new to using Realm. Is there an easy way to save an array to a realm object? I am receiving my data from a JSON REST call: class SomeClass: RLMObject { dynamic var id = 0 dynamic var name = "" dynamic var array: NSArray func checkForUpdates() { // Download JSON data here... The results have an array inside of them. SomeClass.createOrUpdateInDefaultRealmWithObject(SomeNSDictionary) } override class func primaryKey() -> String! { return "id" } } Is it possible to save the array in the JSON

Covert realm list to realm result

半世苍凉 提交于 2020-01-03 19:29:28
问题 just wondering, how do I convert List to Result? Cause I'm doing filtering of region and areas, and when user selected region then area should show only those area in the region. And when I'm asigning my areas to a variable defined as var areas: Results<Area>! , I got the compile error Cannot assign value of type 'List' to type 'Results!' my code is as below if let regionString = self.selectedRegionString { let region = self.realm.objects(Region).filter("name = '\(regionString)'").first self

Differences between filtering Realm with NSPredicate and block

怎甘沉沦 提交于 2020-01-03 18:00:49
问题 I'm wondering about Realm's query performance. Given this code: let result1 = realm.objects(Person.self).filter("age < 30 AND ... AND ...") let result2 = realm.objects(Person.self).filter({ $0.age < 30 }).filter({$0.name .... }).filter({$0.nickname ...}) result1 is created by filtering Person objects using an NSPredicate , while result2 is filtering using the filter method from Swift's collection types. Is there a performance difference between these two approaches to filtering? 回答1: Yes,

Android realm incorrect thread

泪湿孤枕 提交于 2020-01-03 16:54:58
问题 I have 2 Services, one of them is a producer (saving objects to realm), and other reading this objects from realm and sending them to REST service in scheduled tasks. My exception: java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created. Service 1: this.scheduler.schedule("*/2 * * * *", new Runnable() { public void run() { List<Location> locations = dataStore.getAll(Location.class); for(Location l : locations) {

Carthage update error: “GitHub API request failed: Bad credentials”

拈花ヽ惹草 提交于 2020-01-03 16:54:10
问题 Here is my Cartfile: # Kanna HTML parsing library github "tid-kijyun/Kanna" ~> 1.0.0 # Realm database/ORM github "realm/realm-cocoa" When I run carthage update I get this: $ carthage --version Unrecognized command: '--version'. See `carthage help`. $ carthage update --platform OSX *** Fetching realm-cocoa *** Fetching Kanna *** Skipped downloading realm-cocoa.framework binary due to the error: "GitHub API request failed: Bad credentials" *** Checking out realm-cocoa at "v0.98.3" *** Skipped

Error: Object has been deleted or invalidated. (Realm)

不打扰是莪最后的温柔 提交于 2020-01-03 08:21:26
问题 Sometimes (rarely but occurs) I got error Object has been deleted or invalidated. , when trying to modify my model object with a property or inside AFnetworking Block. Can anyone help me to find what I'm doing wrong? Error - Case 1: Code: - (void)myFunction { Model *model = [Model objectForPrimaryKey:1]; if (model) { [self updateModel:model]; } } - (void)updateModel:(Model *)model { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager PUT:@"http://www

how to query from realm database with distinct results java

佐手、 提交于 2020-01-03 07:17:12
问题 I have got a Realm object class, and storing lots of data in there, imagine that I have a String uid; field. I want to get uid names, but on same uid names just only one time, For example uid AA AA BB CC DD BB BB I want to get just AA, BB, CC, DD. Only one time. I looked over realm documentation but couldn't find anything. Thanks for answers. 回答1: UPDATED : You can use distinct() to get distinct entries for an object class. // Returns the set of users that all have a different name

Https Proxy for Realm Object Server not working

别说谁变了你拦得住时间么 提交于 2020-01-03 04:34:07
问题 I can't seem to get the https proxy for my Realm Object Server running. I've followed every step in the docs, which include editing the configuration.yml file to change: proxy.https.enable: true proxy.https.listen_address: :: proxy.https.listen_port: 9443 proxy.https.certificate_path: 'cert_path' proxy.https.private_key_path: 'private_key_path' When I visit http://example.com:9080 it's fine, but visiting https://example.com:9443 doesn't work - I've verified the paths are correct, and the cert

Can't see the database on Realm Object Server

杀马特。学长 韩版系。学妹 提交于 2020-01-03 04:17:24
问题 I have created a method to manage shared table between all users however I can't see this table. I have just remove the "~" character, it works if I leave the "~" character but the table it's only visible by the owner. I don't know why it does not work. Maybe it's not the proper way to share a table between users? static public func setGlobalDatabase(database:String, completion: @escaping (_ realm: Realm?, _ error: Error?) -> Void) { let realmPath = RealmService.REALM_SERVER_DATA + "/" +