realm

Swift Remove Object from Realm

这一生的挚爱 提交于 2019-12-31 21:29:35
问题 I have Realm Object that save list from the JSON Response. But now i need to remove the object if the object is not on the list again from JSON. How i do that? This is my init for realm func listItems (dic : Array<[String:AnyObject]>) -> Array<Items> { let items : NSMutableArray = NSMutableArray() let realm = try! Realm() for itemDic in dic { let item = Items.init(item: itemDic) try! realm.write { realm.add(item, update: true) } items.addObject(item) } return NSArray(items) as! Array<Items> }

Should I define the primary key for each entity in Realm?

心不动则不痛 提交于 2019-12-31 12:13:13
问题 I have noticed that setting PK is not obligatory in Realm and simply can be omitted. But in documentation is stated that: Indexes are created automatically for primary key properties. And I'd like to clear up some questions: 1) What is the default value for PK is defined by Realm, if I don't assign it by myself. Is it hash or whatever ? (If I don't set PK and call [MyRealmObject primaryKey] it returns nil ) 2) If this implicit PK is indexed by default ? Should I worry about it, because if it

Accessing realm database across activities

a 夏天 提交于 2019-12-31 05:25:10
问题 I have 3 different activities. 1 extends Application and realm is configured in this activity. 2. Data is added to Realm from 2nd activity . 3. Data is to be displayed in the 3rd activity. I am unable to do the 3rd part. I am unable to get an instance of Realm in the 3rd activity. The following is Application(1st activity that I mentioned) @Override public void onCreate() { super.onCreate(); Realm.init(this); RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();

Realm data sync not consistent

烈酒焚心 提交于 2019-12-31 04:51:38
问题 I am having an issue where Realm sometimes returns me different data every time I do the same query. Currently I am using an SyncAdapter for uploading. The idea is that we are trying to implement offline mode. So when the User creates an item it get's added to Realm db. I am generating the ID for that item manually by getting the maxId and adding 1000 to it. After that I am sending the itemID to the UploadSyncAdapter where I get the itemById and send it to the backend and the backend returns

Realm returns empty list of object

匆匆过客 提交于 2019-12-31 02:51:05
问题 I want to fetch CropDataList from Farmer Object. when i fetch Farmer Object it's not null, but the cropData list associated with Farmer Object returns empty. I can see database entry via Stetho and there list has one entry. Here's my code. public class Farmer extends RealmObject { @PrimaryKey private String id; private RealmList<CropData> cropData; public String getId() { return id; } public void setId(String id) { this.id = id; } public RealmList<CropData> getCropData() { return cropData; }

The class is missing from the schema for this Realm

左心房为你撑大大i 提交于 2019-12-31 02:46:06
问题 Project setting Android studio 2.3.3 Realm 3.5.0 Source RealmController.java public RealmController(Context context) { try { this.context = context; Realm.init(context); PrintLog("RealmController", "RealmController", "Init realm", LOG_LEVEL_INFO); realmInstance = Realm.getDefaultInstance(); PrintLog("RealmController", "RealmController", "Getting realm instance", LOG_LEVEL_INFO); } catch (Exception err) { PrintLog("RealmController", "RealmController", "Error: " + err.getMessage(), LOG_LEVEL

Realm - module file was created by an older version of compiler

你离开我真会死。 提交于 2019-12-31 01:47:11
问题 I use latest version of xcode and swift 2.2. One of my projects, which I havent open for several month now not building, because of error module file was created by an older version of compiler I tried the following Removed realm frameworks from project, then download the latest version from realm.io and copy the new frameworks to project Building realm by build.sh build from github sources with REALM_SWIFT_VERSION=2.2 and adding to project Neither of these helped, still got error. Any

Import RealmSwift no longer working using CocoaPods

穿精又带淫゛_ 提交于 2019-12-31 01:43:53
问题 The CocoaPods installation of the RealmSwift Kruherson recommended here (or also is recommended from the realm.io page here) basically works - however there is one problem that is remaining in my App using Swift 0.92.3: The following import is no longer recognized ! import RealmSwift What do I still need to do in order to make CocoaPods work under Swift ? Here is the content of my Podfile used : platform :ios, '8.3' use_frameworks! xcodeproj '/Users/XXX/.../MyApp/MyApp.xcodeproj' target

Android - Realm - Object delete - Object is no longer valid to operate on

为君一笑 提交于 2019-12-30 17:26:11
问题 I'm trying to delete an item from a RecyclerView populated from a Realm Database and I'm getting the following error: java.lang.IllegalStateException: Illegal State: Object is no longer valid to operate on. Was it deleted by another thread? Assumptions I guess that I'm trying the access when it's already deleted, but I don't understand where. Context: I'm showing a list of cities and longClicking on an item shows a dialog asking to confirm the deletion. The item is deleted in the database

快速学习Shiro-Shiro的入门

妖精的绣舞 提交于 2019-12-30 13:55:23
4. Shiro安全框架 4.4 Shiro的入门 4.4.1 搭建基于ini的运行环境 (1)创建工程导入shiro坐标 <dependencies> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> 4.4.1 用户认证 认证:身份认证/登录,验证用户是不是拥有相应的身份。基于shiro的认证,是通过subject的login方法完成用户认证工作的 (1)在resource目录下创建shiro的ini配置文件构造模拟数据(shiro-auth.ini) [users] #模拟从数据库查询的用户 #数据格式 用户名=密码 zhangsan=123456 lisi=654321 (2)测试用户认证 @Test public void testLogin() throws Exception{ //1