Вы можете попробовать это:
let loginVc = storyboard?.instantiateViewController(withIdentifier: screenId)
let aObjNavi = UINavigationController(rootViewController: loginVc)
let appDelegate: AppDelegate = (UIApplication.shared.delegate as? AppDelegate)!
appDelegate.window?.rootViewController = aObjNavi
вместо
let vc = storyboard?.instantiateViewController(withIdentifier: screenId)
navigationController?.pushViewController(vc!, animated: true)
Это может помочь вам. Спасибо.
Вы могли бы расширить прототип Array с помощью пользовательского метода:
// check if an element exists in array using a comparer function
// comparer : function(currentElement)
Array.prototype.inArray = function(comparer) {
for(var i=0; i < this.length; i++) {
if(comparer(this[i])) return true;
}
return false;
};
// adds an element to the array if it does not already exist using a comparer
// function
Array.prototype.pushIfNotExist = function(element, comparer) {
if (!this.inArray(comparer)) {
this.push(element);
}
};
var array = [{ name: "tom", text: "tasty" }];
var element = { name: "tom", text: "tasty" };
array.pushIfNotExist(element, function(e) {
return e.name === element.name && e.text === element.text;
});
массива объектов Вы имеете
a.findIndex(x => x.property=="WhateverPropertyYouWantToMatch") <0 ?
a.push(objectYouWantToPush) : console.log("response if object exists");