alibaba / alibaba/HandyJSON

Not work with RealmSwift.xcframework

Open
#475 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.3k
Forks
677
PR merge metrics
No merged PRs in 30d

Description

import Foundation
import RealmSwift
import HandyJSON

class HomeHandyJson: Object, HandyJSON {
// @Persisted

@Persisted var is_expire: String?

@Persisted var use_result_imgs: MyResullt?

required override init(){
super.init()
}
}

class MyResullt: Object, HandyJSON {
@Persisted var imgs: List
required override init(){
super.init()
}
}

class ImgsSSxxx: Object, HandyJSON {
@Persisted var attachment_id: String?
@Persisted var fileName: String?
@Persisted var seal_id: String?
@Persisted var confirm_status: Int?
@Persisted var path: String?
@Persisted var path_thumbnail: String?
@Persisted var fileLength: Int?
@Persisted var oss_url: String?
@Persisted var fileSize: String?
required override init(){
super.init()
}
}

let realm = try! Realm()

try! realm.write {
//can not add to realm and bb is nil 。when i remove @Persisted and Object it can be a HomeHandyJson
let bb = HomeHandyJson.deserialize(from: responseDic["data"] as! [String : Any])

realm.add(bb!)
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the HomeHandyJson, MyResullt, and ImgsSSxxx models and the HandyJSON deserialize call followed by realm.add shown in the issue. Reproduce the case with RealmSwift.xcframework, then compare it with the version where @Persisted and Object are removed. Done means determining why deserialization returns nil or the object cannot be added to Realm and documenting a verified result.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.