GithubHelp home page GithubHelp logo

0xjmp / objectmapper-realm Goto Github PK

View Code? Open in Web Editor NEW
177.0 177.0 44.0 48 KB

An ObjectMapper extension that serializes arbitrary JSON into Realm's List class

License: Other

Ruby 16.60% Swift 74.07% Objective-C 9.33%

objectmapper-realm's Introduction

Returning Soon

objectmapper-realm's People

Contributors

0xjmp avatar akovalov avatar avatar7 avatar fernandomatal avatar gpolyansky avatar guerrix avatar knine79 avatar markus-mohemian avatar peterek avatar simone-gasparini 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

objectmapper-realm's Issues

Swift 3

Is there any plans to update to Swift 3 ?

And the latest version of ObjectMapper and Realm ?

//Kim

Error with XCode 11.4 and spm

Hi!

After the XCode 11.4 update, we can't successfully compile our app, the error is the infamous "Command CompileSwiftSources failed with a nonzero exit code" and the error log (huge) is this:

error spm.txt

and besides this, we have a warning telling "/Users/alberto/Library/Developer/Xcode/DerivedData/tracciabilitapp-cemvoiaebzivuadnukxjxudnlrgs/SourcePackages/checkouts/ObjectMapper/Package.swift: ignoring broken symlink /Users/alberto/Library/Developer/Xcode/DerivedData/tracciabilitapp-cemvoiaebzivuadnukxjxudnlrgs/SourcePackages/checkouts/ObjectMapper/Sources/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper/ObjectMapper"

Already tried a clean and build, refetched packages and everything but nothing worked :(

Singleton User object

Hi,

Please if you can share example of how can we use ObjectMapper and Realm for singleton object.

I have implemented StaticMappable and Object. but primary key is creating issue.

SWIFT_VERSION '3.0' is unsupported

Pod install is giving me this error

SWIFT_VERSION '3.0' is unsupported, supported versions are: 4.0, 4.2, 5.0. (in target 'ObjectMapper+Realm')

array nil

I'm sorry to bother you but I have encountered some problems in using realm
json like this:

 "result" : [
    {
      "acReg" : "8282",
      "acType" : "A320",
      "arrivalCh" : null,
      "arrivalTime" : "04:55",
      "captain" : "康玉磊",
      "cleanFeedback" : null,
      "createBy" : null,
      "createTime" : null,
      "crewCount" : "10",
      "crewLinkLine" : "2",
      "departureCh" : null,
      "enterTime" : "05:10",
      "flightDate" : "2018-05-18",
      "flightDateEnd" : null,
      "flightDateStart" : null,
      "flightId" : "273244",
      "flightLine" : null,
      "flightNo" : "QW9775",
      "flightStatus" : "开舱门",
      "flightSummary" : null,
      "flightVoyage" : "青岛-长沙",
      "h001" : "RY1607010",
      "h001Name" : "赵子怡",
      "h003" : [
        {
          "crewName" : "徐莹莹",
          "tsFlag" : "乘务员",
          "workcode" : "RY1604039"
        },
        {
          "crewName" : "王秋雯",
          "tsFlag" : "乘务员",
          "workcode" : "RY1705016"
        }
      ],
      "h003List" : null,
      "is3Certificate" : "0",
    }

and i use ObjectMapper_Realm to handle it like this:

class FlightPlanModel: Object,Mappable {
    @objc dynamic  var preparationId:Int = 1    //行前准备id
    var  h003:List<h003Model>?           //乘务员3
    @objc dynamic  var planTime:String?    = nil      //计划时间   
    required convenience init?(map: Map) {
        self.init()
    }
    func mapping(map: Map)
    {
        preparationId <- map["preparationId"]
        h003 <- (map["h003"],ListTransform<h003Model>())
        planTime <- map["planTime"]
    }
    override static func primaryKey()->String?{
        return "preparationId"
    }
}

class h003Model: Object ,Mappable {
    @objc dynamic var workcode:String = ""
    @objc dynamic var crewName:String = ""
    @objc dynamic var tsFlag:String? = nil

    required convenience init?(map: Map) {
        self.init()
    }
    func mapping(map: Map)
    {
        workcode <- map["workcode"]
        crewName <- map["crewName"]
        tsFlag <- map["tsFlag"]
    }
}
}

but when i get data and

try! realm.write {
                            for model in modelArr{
                                
                                realm.add(model, update: true)
                            }
                        }

i find h003 is nil...
can u help me ? thanks a lot~!!!!

Swift 4?

I have been used it, in my project, but now I am unable to move to new beta xcode, which doesn't support version of Swift used in ObjectMapper-Realm.

Carthage import failed

I edit the Cartfile, put github "jakenberg/ObjectMapper-Realm" in to Cartfile, but when carthage update, there no framework on iOS folder.

support watchos

Do you have any plans to support watchos?
(watchOS 4.0) is not compatible with ObjectMapper+Realm (0.5), which does not support watchos

Primary key property 'id' does not exist on object

I try to figure out an exception:

Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'id' does not exist on object 'Photo''

I have the object Photo:

class Photo: Object, Mappable {
	dynamic var id: Int!
	dynamic var number: Int!
	dynamic var url: String!
	
	override class func primaryKey() -> String? {
		"id"
	}
	
	required init?(map: Map) {
	}
	
	override required init() {
		super.init()
	}
	
	func mapping(map: Map) {
		id <- map["id"]
		number <- map["num"]
		url <- map["url"]
	}
}

I get the exception on startup of my project.
I use Realm 4.1.1

If I comment primaryKey func project starts successful.
How can I figure out it?

Can't use dynamic var with List<Object>

This feature doesn't work, so the readme should reflect it. The effect of this is you can't use ListTransform and still access properties via dot syntax.

Unless I'm missing something.

Help with JSON:API + Realm + ObjectMapper

I have been struggling to find any implementation that supports a robust API with http://jsonapi.org/format/ I'm especially stuck when it comes to translating partial updates that support the json api spec.

class Challenge: Object, Mappable {
    
    @objc dynamic var id = ""
    @objc dynamic var action = ""

     var players = List<Player>()
     
      override static func primaryKey() -> String? {
        return "id"
    }

    func mapping(map: Map) {
        
        id <- map["id"]
        action <- map["attributes.action"]
        players <- (map["relationships.players.data"], ListTransform<Player>())
    }
}

Now the problem i'm having is these relationships are stubs, they are partial updates. My problem is if realm already has these items they are are completely nilled out. It causes complete chaos because as these relationships are added, existing properties get wiped, and then come back once a again once the full compound document gets processed from the include

let json = JSON(data as Any)
guard let payloadDict = json.dictionary, let dataDict = payloadDict["data"], let includedArray = payloadDict["included"]?.arrayObject else { abort() }
guard let challenge = Mapper<Challenge>().map(JSONObject: dataDict) else {
    abort()
}
let realm = try! Realm()
// OK this is going to create a bunch of stubbed players nilling out the entire model if it already exists
try! localRealm.write {
    localRealm.create(type(of: object), value: challenge, update: true)
}

guard let players = Mapper<Player>().mapArray(JSONObject: includedArray) else {
    abort()
}
// .... truncated, save players in realm write block

The other problem is that compounds/includes are put into a included array of any type that was asked to be included, so even Mapper<Player>().mapArray(JSONObject: includedArray) isn't very correct, it is only accidentally correct. This is now becoming extremely unwieldy to manage

Example response, this is for a collection

{
  "data": [
    {
      "id": "82172c36-ff02-44c5-9532-5cfb017a35b1",
      "type": "challenge",
      "attributes": {
        "action": "Dr. Greger’s Daily Dozen",
        "created_at": "2018-04-30T20:51:26.869Z",
      },
      "relationships": {
        "players": {
          "data": [
            {
              "id": "d38fc35f-618a-437a-9aed-8f9abe9f8ef0",
              "type": "player"
            },
            {
              "id": "2032d502-e571-4264-8842-899b29d8f5af",
              "type": "player"
            },
            {
              "id": "8e274631-8086-4e25-9098-6edd0b9ef50b",
              "type": "player"
            },
            {
              "id": "d511f92b-ad76-48df-8260-189ddb4bbb42",
              "type": "player"
            },
          ]
        },
        "owner": {
          "data": {
            "id": "98f8191b-6baf-485f-b3e3-e13775268b21",
            "type": "user"
          }
        }
      }
    }],
"included": [
    {
      "id": "d38fc35f-618a-437a-9aed-8f9abe9f8ef0",
      "type": "player",
      "attributes": {
        .... truncated
      }
    },]

This is what i actually need the mapper to do

    id <- map["id"]
    action <- map["attributes.action"]
try! realm.write {
    players <- realm.create(Player.self, value: [{"id": "1"}, {"id": "2"}], update: true) // PARTIAL UPDATE FOR JSON API SPEC
}

I'm at the point where I have stopped trying to model relationships with Realm anymore. I simply store foreign keys and use predicates. I haven't seen a single example on the internet of someone using json api and realm. I can only find lots of bikeshedding, or json api with nothing more complicated than reading attritubes, no relationships, no compound documents. If anyone can point me in the write direction, would be greatly appreciated!

Use of unresolved identifier 'ListTransform' After POD UPDATE

Hi,

I have updated ObjectMapper and now I have an error message in my realm class.
Use of unresolved identifier 'ListTransform'

When I add manualy "Struct ListTransform" in my realm class, the error is solved.

I think the ListTransform was not imported correctly in ObjectMapper-realm...

Do you have any idea ?

Best regard's

Mapping an array of Int - List<Int>()

Whats everyone doing regarding to mapping an array of Int to a list of integers now that this is supported in Realm?

e.g "ids": [123, 456, 789]

Would this be acceptable?

import Foundation
import ObjectMapper
import RealmSwift

public struct IntListTransform: TransformType {

    public typealias Object = List<Int>
    public typealias JSON = [Any]

    public func transformFromJSON(_ value: Any?) -> List<Int>? {
        guard let intValues = value as? [Int] else {
            return nil
        }
        let objects = intValues.compactMap {
            Int($0)
        }
        let list = List<Int>()
        list.append(objectsIn: objects)
        return list
    }

    public func transformToJSON(_ value: List<Int>?) -> [Any]? {
        Fatal.notImplemented("Implementation not required")
    }
}

Feature request: mapping realm object -> object

Realm objects are linked with managed context and so they can be used only in the same thread (maybe in the same run loop). Could you add a mapping to something which is not linked managed context

Mapping List of String or Integer

How to map a list of Integer or String object ? I still can't solve it

class X: Object, StaticMappable {
 var strings = List<RealmString>()

 class func objectForMapping(map: Map) -> BaseMappable? {
     return X()
 }

func mapping(map: Map) {
      strings <- (map["strings"], ListTransform<RealmString>())
}
}

class RealmString: Object, StaticMappable {
 dynamic var value = ""
 
 class func objectForMapping(map: Map) -> BaseMappable? {
     return RealmString()
 }
 
 func mapping(map: Map) {
     value <- map
 }

}

Json should be like this :
{
x: ["a","b","c"]
}

Please release Swift 3 support

It appears as though these changes are ready to go and the podspec just needs to be updated. Would you mind doing this?

How can I do same with dictionary where JSON is in the form of dictionary

This is the below code

class UserInfo:Object,Mappable
{
var name:String?
var identifier:String?
var accountType:String?
var devices:[String:UserDevice]?
required init?(map: Map) {

}

// Mappable
func mapping(map: Map) {
name <- map["username"]
identifier <- map["identifier"]
accountType <- map["accountType"]
devices <- map["devices"]
}
}

class UserDevice:Object,Mappable
{
var deviceName:String?
var deviceType:String?
var deviceIdentifier:String?

required init?(map: Map) {

}

// Mappable
func mapping(map: Map) {
deviceName <- map["name"]
deviceType <- map["type"]
deviceIdentifier <- map["identifier"]
}
}

this is my JSON:

{
username = santhosh;
"identifier" = "IDJSDJSJS";
configstatus = SET;
configtype = DEFAULT;
"data_center" = "evs.idrive.com";
devices = {
"Ankita\LKKKK" = {
identifier = LJJDFDD;
name = "Ankita iPAD";
type = iPad;
};
"ARUN\LKKKHJH" = {
identifier = LJJDFDFFD;
name = "ARUN iPhone";
type = ipHone;
};

accountStatus = 2;
acctype = Test;

Using ObjectMapper-Realm with Custom objects

class SignUpResponseBody : Object, Mappable {

var data : List<SignUpResponseData>?
var meta : List<Meta>?
var status : String?

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    data <- (map["data"], ListTransform<SignUpResponseData>())
    meta <- (map["meta"], ListTransform<Meta>())
    status <- map["status"]
}

}

class SignUpResponseData : Object, Mappable {

var id : Int?
var email : String?
var name : String?
var organisationName : String?
var worktype : String? //Organisation or Individual 0 is org, 1 is individual
var addressOne : String?
var addressTwo : String?
var mobile : String?
var authToken : String?
var localityInfo : List<Locality>?
var profileImage : String?
var role : String? //Builder or Channel Partner
var channelPartnerLocalities : List<ChannelPartnerLocalityAttributes>?
var builderInfo : List<BuilderInfo>?
var designation : String?
var city : String?

override static func primaryKey() -> String? {
    return "id"
}

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    id <- map["id"]
    email <- map["email"]
    name <- map["name"]
    organisationName <- map["organization_name"]
    worktype <- map["work_type"]
    addressOne <- map["address_one"]
    addressTwo <- map["address_two"]
    mobile <- map["mobile"]
    authToken <- map["authentication_token"]
    localityInfo <- (map["locality_info"], ListTransform<Locality>())
    profileImage <- map["profile_image"]
    role <- map["role"]
    channelPartnerLocalities <- (map["channel_partner_user_localities"], ListTransform<ChannelPartnerLocalityAttributes>())
    builderInfo <- (map["builder_info"], ListTransform<BuilderInfo>())
    designation <- map["designation"]
    city <- map["city"]
}

}

class BuilderInfo : Object, Mappable {

var id : Int?
var name : String?

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    id <- map["id"]
    name <- map["name"]
}

}

class Locality : Object, Mappable {

var id : Int?
var name : String?
var city : String?

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    id <- map["id"]
    name <- map["name"]
    city <- map["city"]
}

}

class ChannelPartnerLocalityAttributes : Object, Mappable {

var userId : Int?
var name : String?

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    userId <- map["id"]
    name <- map ["name"]
}

}

In my call of type SignUpResponseBody,

response.data is being collected as nil. What am I doing wrong? I have tried collecting the object with just ObjectMapper and it works just fine. Im printing out my response and key "data" does have an object of type SignUpResponseData in it.

{ (response,error) in
print((response!.data)!) ----> returns nil
}

Also, yes I know I should be doing checks before collecting data, this is just to test it out. I have also checked my key value pairs and they are correct.

Thanks in advance

Carthage build failed

Hi,

I'm getting this error when installing the library using Carthage:

*** Building scheme "ObjectMapper+Realm" in ObjectMapper+Realm.xcworkspace
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -workspace /Users/ml/Developer/Carthage_DuckDuckDefine/Carthage/Checkouts/ObjectMapper-Realm/ObjectMapper+Realm.xcworkspace -scheme ObjectMapper+Realm -configuration Release -derivedDataPath /Users/ml/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/ObjectMapper-Realm/0.5 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/g2/x_y6vlnx547cwbz_mkgnc7v00000gn/T/ObjectMapper-Realm SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/g2/x_y6vlnx547cwbz_mkgnc7v00000gn/T/carthage-xcodebuild.siJOyX.log

This is what's in the Cartfile:

github "Jakenberg/ObjectMapper-Realm"

When I ran carthage update --platform iOS, the installation stops, producing the error above.

Any help would be very much appreciated.

Dictionary parsing using Realm?

How do I parse a Dictionary response using Realm? Please help with example.

Here is my response -

{
questions = (
{
"_id" = qId1;
answerKey = 1001;
details = {
createdBy = {
avatar = "http://icons.iconarchive.com/icons/mattahan/ultrabuuf/256/TV-Smith-icon.png";
name = "Sir Devender";
userId = 1;
};
createdOn = "";
description = {
files = "";
text = "A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train?";
};
options = (
{
file = "";
num = 1;
text = "120 metres";
type = text;
},
{
file = "";
num = 2;
text = "180 metres";
type = text;
},
{
file = "";
num = 3;
text = "324 metres";
type = text;
},
{
file = "";
num = 4;
text = "150 metres";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId2;
answerKey = 1000;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "A train 125 m long passes a man, running at 5 km/hr in the same direction in which the train is going, in 10 seconds. The speed of the train is:";
};
options = (
{
file = "";
num = 1;
text = "45 km/hr";
type = text;
},
{
file = "";
num = 2;
text = "50 km/hr";
type = text;
},
{
file = "";
num = 3;
text = "54 km/hr";
type = text;
},
{
file = "";
num = 4;
text = "55 km/hr";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId3;
answerKey = f;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Electrons are larger than molecules.";
};
type = tf;
};
},
{
"_id" = qId4;
answerKey = 1001;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Suppose you are a mathematics professor who wants to determine whether or not your teaching of a unit on probability has had a significant effect on your students. You decide to analyze their scores from a test they took before the instruction and their scores from another exam taken after the instruction. Which of the following t-tests is appropriate to use in this situation?";
};
options = (
{
file = "";
num = 1;
text = "Dependent samples.";
type = text;
},
{
file = "";
num = 2;
text = "Heterogenous samples.";
type = text;
},
{
file = "";
num = 3;
text = "Homogenous samples.";
type = text;
},
{
file = "";
num = 4;
text = "Independent samples.";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId5;
answerKey = 1000;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "A nurse is assessing a client who has pneumonia. Which of these assessment findings indicates that the client does NOT need to be suctioned?";
};
options = (
{
file = "";
num = 1;
text = "Diminished breath sounds.";
type = text;
},
{
file = "";
num = 2;
text = "Absence of adventitious breath sounds.";
type = text;
},
{
file = "";
num = 3;
text = "Inability to cough up sputum.";
type = text;
},
{
file = "";
num = 4;
text = "Wheezing following bronchodilator therapy.";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId6;
answerKey = f;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "All trees except pine trees molt their leaves in the fall.";
};
type = tf;
};
},
{
"_id" = qId7;
answerKey = 1001;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "What is the average effective radiation dose from chest CT?";
};
options = (
{
file = "";
num = 1;
text = "1-8 mSv";
type = text;
},
{
file = "";
num = 2;
text = "8-16 mSv";
type = text;
},
{
file = "";
num = 3;
text = "16-24 mSv";
type = text;
},
{
file = "";
num = 4;
text = "24-32 mSv";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId8;
answerKey = 1000;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Idaho is widely known for its:";
};
options = (
{
file = "";
num = 1;
text = Apples;
type = text;
},
{
file = "";
num = 2;
text = Corn;
type = text;
},
{
file = "";
num = 3;
text = Potatoes;
type = text;
},
{
file = "";
num = 4;
text = Wheat;
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId9;
answerKey = f;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Water is less dense in its liquid state.";
};
type = tf;
};
},
{
"_id" = qId10;
answerKey = 1001;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Which of the following artists is known for painting the ceiling of the Sistine Chapel?";
};
options = (
{
file = "";
num = 1;
text = Botticelli;
type = text;
},
{
file = "";
num = 2;
text = "da Vinci";
type = text;
},
{
file = "";
num = 3;
text = Michelangelo;
type = text;
},
{
file = "";
num = 4;
text = Raphael;
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId11;
answerKey = 1000;
details = {
createdBy = {
avatar = "http://findicons.com/files/icons/1072/face_avatars/300/a02.png";
name = "Sir Tarun";
userId = 2;
};
createdOn = "";
description = {
files = "";
text = "The term operant conditioning refers to the learning situation in which:";
};
options = (
{
file = "";
num = 1;
text = "A familiar response is associated with a new stimulus.";
type = text;
},
{
file = "";
num = 2;
text = "Individual associations are linked together in sequence.";
type = text;
},
{
file = "";
num = 3;
text = "The learner\U2019s response leads to reinforcement.";
type = text;
},
{
file = "";
num = 4;
text = "Verbal responses are made to verbal stimuli.";
type = text;
}
);
type = mcq;
};
},
{
"_id" = qId12;
answerKey = f;
details = {
createdBy = {
"_id" = tempid6;
avatar = "http://icons.iconarchive.com/icons/hopstarter/superhero-avatar/256/Avengers-Black-Widow-icon.png";
name = "Alecto Carrow";
role = ta;
};
createdOn = "";
description = {
files = "";
text = "Dieting combined with consistent exercise will usually aid in weight loss.";
};
type = tf;
};
}
);
submission = {
qId1 = {
answerString = 1001;
};
qId10 = {
answerString = 1001;
};
qId11 = {
answerString = 1001;
};
qId12 = {
answerString = f;
};
qId2 = {
answerString = 1001;
};
qId3 = {
answerString = f;
};
qId4 = {
answerString = 1001;
};
qId5 = {
answerString = 1001;
};
qId6 = {
answerString = f;
};
qId7 = {
answerString = 1001;
};
qId8 = {
answerString = 1001;
};
qId9 = {
answerString = f;
};
};
}

Carthage failed at Archive phase

I use carthage update --platform iOS --no-use-binaries to build the package.
In the Cartfile, jakenberg/ObjectMapper-Realm == 1.0

then failed.

in the error dialog, it shows ( swift version: 5.2.4, xcode 11.5)

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Carthage/Checkouts/ObjectMapper-Realm/Pods/Target Support Files/Pods-ObjectMapper_Realm/Pods-ObjectMapper_Realm.release.xcconfig: unable to open file (in target "ObjectMapper_Realm" in project "ObjectMapper+Realm") (in target 'ObjectMapper_Realm' from project 'ObjectMapper+Realm')

** ARCHIVE FAILED **

I don't get this error on building other package through carthage, do you have any solution or anybody get same situation?

Facing difficulty in creating Model for following JSON Structure.

{ "title": "Recent Uploads tagged dogs", "link": "https://www.flickr.com/photos/tags/dogs/", "description": "", "modified": "2017-05-24T04:51:14Z", "generator": "https://www.flickr.com", "items": [ { "title": "20170520-NSW3-3549", "link": "https://www.flickr.com/photos/k9mom2008/34857898535/", "media": { "m": "https://farm5.staticflickr.com/4250/34857898535_aebc9c9570_m.jpg" }, "date_taken": "2017-05-20T13:33:33-08:00", "description": " <p><a href=\"https://www.flickr.com/people/k9mom2008/\">K9Mom2008</a> posted a photo:</p> <p><a href=\"https://www.flickr.com/photos/k9mom2008/34857898535/\" title=\"20170520-NSW3-3549\"><img src=\"https://farm5.staticflickr.com/4250/34857898535_aebc9c9570_m.jpg\" width=\"240\" height=\"160\" alt=\"20170520-NSW3-3549\" /></a></p> ", "published": "2017-05-24T04:51:14Z", "author": "[email protected] (\"K9Mom2008\")", "author_id": "21376052@N06", "tags": "dogs nsw3" } ] }

I am able to create whole structure, except media which contains sub Dictionary
How do I handle for that?

ListTransform not working with subclassed types

I have an object with a list as a variable. the type of the list is, say: Child. The child class does inherit from Parent. To get it work with Realm, the Type of the Parent class should be StaticMappable, rather then Mappable.

Subclassing and Realm: tristanhimmelman/ObjectMapper#462

Now I stuck on this:
bildschirmfoto 2017-02-13 um 18 16 27

I found in your struct ListTransform, that the generic Type T has to be Mappable. Why not BaseMappable? This will solve the compile-error.

To reproduce:

import ObjectMapper
import RealmSwift
import ObjectMapper_Realm

class Parent: Object, StaticMappable {
    dynamic var name = ""
    
    class func objectForMapping(map: Map) -> BaseMappable? {
        return Parent()
    }
    
    func mapping(map: Map) {
        name <- map["name"]
    }
}

class Child: Parent {
    dynamic var onlyMyType = 0
    
    override class func objectForMapping(map: Map) -> BaseMappable? {
        return Child()
    }
    
    override func mapping(map: Map) {
        super.mapping(map: map)
        onlyMyType <- map["only_my_type"]
    }
}

class ManyChilds: Object, Mappable {
    var childs = List<Child>()
    
    required convenience init?(map: Map) {
        self.init()
    }
    
    func mapping(map: Map) {
        childs <- (map["childs"], ListTransform<Child>()) // here we have the error, because Child is not of type `Mappable`
    }
}

ObjectMapper (2.2.2)
RealmSwift (2.4.2)
ObjectMapper+Realm (0.2)

Swift 3.0.2
Xcode: 8.2.1

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.