我有三个通过列表嵌套的对象,如下所示:
class Canteen: Object {
dynamic var name: String?
let lines = List<Line>()
}
class Line: Object {
dynamic var name: String?
let meals = List<Meal>()
}
class Meal: Object {
dynamic var name: String?
dynamic var vegan: Bool = false
}
Run Code Online (Sandbox Code Playgroud)
获得所有线路和餐点的所有食堂都没有问题.我现在正在做的是:
let predicate = NSPredicate(format: "name == %@", selectedCanteenType.rawValue)
canteens = realm.objects(Canteen).filter(predicate)
Run Code Online (Sandbox Code Playgroud)
但现在我只需要素食主义者的饭菜.因此,我希望获得所有线路的选定食堂,但只有纯素食品.这是否可以在领域中筛选检索到的对象中的列表?
是否有任何优雅的方法从数组中删除对象是一个数组的一部分?我一直在使用React和Redux一段时间,但是每次我必须删除或插入数据而不改变状态时会卡住几个小时.
reducer是一个数组,包含具有ID的对象和带有对象的另一个数组,如下所示:
[
{ id:123,
items:[
{ id: abc,
name: albert
},
...
]
},
...
]
Run Code Online (Sandbox Code Playgroud)
我收到两个ID,需要删除带有ID的项目abc
.
由于我是JavaScript和React的新手,我在确定正确的语法时确实遇到了问题.
这是我的问题:
_handleDrop(files)
应该调用函数_validateXML(txt)
但不调用.我收到此错误Uncaught TypeError: this._validateXML is not a function
,无法弄清楚原因.callBack _handleDrop(files)
运行正常.
当我尝试这种语法时,_validateXML:function(txt)
我会在编译时立即收到错误.这是因为ecmascript?
import React from 'react';
import './UploadXML.scss';
import Dropzone from 'react-dropzone';
import xml2js from 'xml2js';
export default class UploadXML extends React.Component {
constructor() {
super();
this._validateXML = this._validateXML.bind(this);
}
_validateXML(txt) {
console.log('Received files: ', txt);
}
_handleDrop(files) {
if (files.length !== 1) {
throw new Error("Please upload a single file");
}
var file = files[0];
console.log('Received files: ', file);
this._validateXML(file);
}
render() …
Run Code Online (Sandbox Code Playgroud) 我有下面的portlet view.xhtml
:
<?xml version="1.0"?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:body>
<h:form>
<h:commandButton value="TESTButton" action="#{navigationViewBean.submit}" />
<h:outputText value="TESTGetter: #{navigationViewBean.testField}" />
</h:form>
</h:body>
</f:view>
Run Code Online (Sandbox Code Playgroud)
而这个托管bean:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name = "navigationViewBean")
@RequestScoped
public class NavigationViewBean {
private String testField;
public boolean lol = false;
public void submit() {
System.out.print("TEST BUTTON INVOKED");
}
public String getTestField() {
System.out.print("TEST GETTER INVOKEDx");
return testField;
}
public void setTestField(String testField) {
this.testField = testField;
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试做的唯一一件事就是调用一个方法来打印我的控制台.问题在于,无论我做什么,都不会调用action方法.正确调用getter方法.
我究竟做错了什么?
在我的PFQueryTableViewController
,习惯PFTableViewCell's
没有任何分隔符,我不知道为什么.
googeling时我没有找到任何东西.
我究竟做错了什么?
class CategoryTableViewController: PFQueryTableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.loadObjects()
}
// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String?) {
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Configure the PFQueryTableView
self.parseClassName = "Category"
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// Mark - …
Run Code Online (Sandbox Code Playgroud) ios parse-platform swift pfquerytableviewcontrolle pftableviewcell
ios ×2
javascript ×2
reactjs ×2
swift ×2
ecmascript-6 ×1
immutability ×1
jsf ×1
liferay ×1
mutation ×1
paradigms ×1
portlet ×1
react-jsx ×1
realm ×1
redux ×1
syntax-error ×1