如何在使用Realm检索数据时返回带有值的类?我正在尝试使用此代码,但不允许使用swift 3:
static func getInfoById(id: String) -> DataInfo {
let scope = DataInfo ()
let realm = try! Realm()
scope = realm.objects(DataInfo.self).filter("IdInfo == %@", id)
return scope
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试读取 Firebase 上的数据库,但没有任何反应。
我的数据库非常简单,只有一个节点gps,里面有两个节点:lat当前lng我正在使用 JavaScript。
firebase.js所有脚本都以、firebase-database.js和 的形式加载到标头上firebase-app.js。我的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://www.gstatic.com/firebasejs/4.8.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.8.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.8.0/firebase-app.js"></script>
<style>
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var firebase = require("firebase/app");
require("firebase/auth");
require("firebase/database");
var config = {
apiKey: "AIzaxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxxxxxx.firebaseio.com",
projectId: "xxxxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxxxxxxxxx"
};
firebase.initializeApp(config); …Run Code Online (Sandbox Code Playgroud) 我有这个:
List<string> list = new List<string>();
list.Add("a-b-c>d");
list.Add("b>c");
list.Add("f>e");
list.Add("f>e-h");
list.Add("a-d>c-b");
Run Code Online (Sandbox Code Playgroud)
我想删除重复项.在这种情况下,重复是"abc> d"和"ad> cb".两者都有相同的字符,但是以不同的顺序排列.我尝试过:
list.Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
但没有奏效!