Posts

Showing posts from August, 2013

c# - How to easily create a ListTreeView with ObjectListView? -

i need create listtreeview ( objeclistview ) supports following features: folders, subfolders , items within these. drag , drop. detect path of each folder/item. can give me examples?

android - CircleImageView crashes when used as tablayout -

i have xml set below. tab_icon_simple.xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:gravity="center" android:layout_height="match_parent"> <imageview android:id="@android:id/icon" android:layout_width="@dimen/size_tab_image" android:scaletype="fitcenter" android:layout_height="@dimen/size_tab_image"/> // add circleimageview here conditionally use render profile image. cover default imageview icon. <de.hdodenhof.circleimageview.circleimageview android:id="@+id/profile_icon" android:layout_width="@dimen/size_tab_image" android:scaletype="fitcenter" android:visibility="gone" ...

po - No need to check this! skip -

so i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute isso i'm trying struggling execute single line in text f import java.util.scanner; import java.io.*; public class hello { public static void main(string[] args) throws ioexception { scanner keyboard = new scanner(system.in); system.out.print(); string response = keyboard.nextline(); file infile = new file(response); scanner route = new scanner(infile); while () { system.out.print("); string word = keyboard.next(); string street = route.next(); string stopnum = route.next(); you closing file after read 1 "line" (actually, i'm not sure how many lines you're reading - don't call nextline ). are...

c# - LINQ in .NET MVC: Any advantage to creating a ViewModel vs. joining tables? -

Image
i'm working on simple project have data in 2 tables need return view controller. i'm aware of 2 methods in .net, first create model class, add properties need access in view, creating viewmodel. so: public class beerlistviewmodel { public int id { get; set; } public string name { get; set; } public string brewername { get; set; } public string city { get; set; } public string country { get; set; } public string weburl { get; set; } public string imageurl { get; set; } public double alcoholcontent { get; set; } public string beertype { get; set; } public int calories { get; set; } public double carbs { get; set; } public string notes { get; set; } public int countofreviews { get; set; } } then set model linq statement selecting dbset , instantiating viewmodel , load properties need send view, return model view, so: //1. instantiate db odetobeerdb _db = new odetobeerdb(); // get: reviews public actionr...

casting - c++ same calculation assigned to int or double gives different results, but only for certain values (is 64.02 a magic number in c++?) -

this question has answer here: is floating point math broken? 20 answers i tried assign calculation result variable, , print out. however, depending on type of variable it's assigned to, results different. unexpected results happened values specific calculation. int main() { // above 64.02 give unexpected results // e.g. (100.02 - 100.0) * 100.0 int ((64.02 - 64.0) * 100.0); double b ((64.02 - 64.0) * 100.0); cout<<"result: "<<a<<endl; // result: 1, expected result: 2 cout<<"result: "<<b<<endl; // result: 2, expected result: 2 // below 64.02 give right results int c ((63.02 - 63.0) * 100.0); double d ((63.02 - 63.0) * 100.0); cout<<"result: "<<c<<endl; // result: 2, expected result: 2 cout<<"result: "<<d...

postgresql - postgres: why isn't this query using the GIN index on the array value? -

sql: create temporary table objs (obj_id integer); create temporary table sets (obj_id integer[], somecount smallint); insert objs select generate_series(0,10000); insert sets select array[p1.obj_id, p2.obj_id,p3.obj_id], generate_series(0,100) objs p1 cross join objs p2 cross join objs p3 p2.obj_id = p1.obj_id + 1 , p3.obj_id = p2.obj_id + 1; create index on sets using gin(obj_id); set enable_seqscan = off; explain analyze select * sets obj_id @> array[1,2]::integer[]; yields: query plan ------------------------------------------------------------------------------------------------------------------------ seq scan on sets (cost=10000000000.00..10000021039.74 rows=25 width=34) (actual time=0.037..333.496 rows=202 loops=1) filter: (obj_id @> '{1,2}'::integer[]) rows removed filter: 1009697 planning time: 0.727 ms execution...

I m not able to click on a button in a web page using selenium in python -

what wrong in below code import os import time selenium import webdriver driver = webdriver.firefox() driver.get("http://x.x.x.x/html/load.jsp") elm1 = driver.find_element_by_link_text("load") time.sleep(10) elm1.click() time.sleep(30) driver.close() the page source <body> <div class="formcenterdiv"> <form class="form" action="../load" method="post"> <header class="formheader">loader</header> <div align="center"><button class="formbutton">load</button></div> </form> </div> </body></html> i want click on button load. when ran above code getting error selenium.common.exceptions.nosuchelementexception: message: unable locate element: load as documentation says , find_elements_by_link_text works on a tags: use when know link text used within anchor tag. strategy, firs...

malloc - Associating metadata in custom memory allocator for C89/C90 -

let's have following implementation custom memory allocator wrapping standard malloc , free library functions: #include <stdlib.h> #include <stddef.h> struct metadata { void *private; size_t len; char data[1]; }; void *custom_malloc(size_t len) { struct metadata *mtdata; mtdata = malloc(offsetof(struct metadata, data) + len); if (mtdata == null) return null; mtdata->private = null; /* or pointer implementation data */ mtdata->len = len; return mtdata->data; } void custom_free(void *ptr) { struct metadata *mtdata; char *bytes; bytes = ptr; mtdata = (struct metadata *)(bytes - offsetof(struct metadata, data)); /* stuff mtdata->private , mtdata->len */ free(mtdata); } is implementation valid (for c89/c90)? ultimately, goal allocate contiguous memory len bytes requested user, associate them metadata. si...

ios - How to use geometry from scene file with multiple objects (geometries)? -

i have blender file i've exported dae/collada , converted scenekit's scene file using xcode. i'm having trouble using geometry scene file. the scene file ("model.scn") pretty basic: group (no geometry element) shape1 (geometry element) shape2 (geometry element) shape3 (geometry element) when i'm trying use model, i'm unable use combined geometry of 3 shapes scngeometry used scnphysicsbody. i've tried various approaches, don't work: approach 1 let scene = scnscene(named: "art.scnassets/model.scn")! let node = scene.rootnode.childnode(withname: "group", recursively: true)! guard let geo = node.geometry else { return } // node.geometry nil returns here let physicsbody = scnphysicsbody(type: .kinematic, shape: scnphysicsshape(geometry: geo)) // need custom/aggregate geometry approach 2 let scene = scnscene(named: "art.scnassets/model.scn")! let geonode = scnnode() let node1 = scene.rootnode.chil...

javascript - Bottom button does not shift video to bottom where as left and right is working fine -

Image
i've put video inside div, 1 zoom bar zoom video , 4 buttons on each side move video accordingly in left, right, top, bottom side after zooming. the problem is, left , right button working top , bottom buttons not move video. in example, video panning not working on top , bottom side. if (parsefloat(document.getelementbyid("myvideo").style.top)<=0) { console.log(parsefloat(document.getelementbyid("myvideo").style.top)); $("#myvideo").css({"top":parsefloat(document.getelementbyid("myvideo").style.top)+1+"%"}); code link- https://pastebin.com/kk6xzulu check code in top , bottom functions. you're missing parentheses, otherwise you'd concatenating 1 string, ending 30 + 1 + '%' gives "301%" etc. try more verbose approach, remove unwanted characters styles, parse them , add them properly, , use them var top = document.getelementbyid("m...

angular - While Implementing CanActivate Guard Error as : No provider for HRComponent -

while implementing canactivate guard im getting error : no provider hrcomponent import { component, oninit } "@angular/core" import { activatedroute, canactivate } "@angular/router" import { loginservice } "../../services/loginservice" @component({ templateurl:"../../../templates/hrmodule/hrmodule.html" }) export class hrcomponent implements canactivate { constructor(private loginservice: loginservice) { } canactivate(){ debugger; alert('active'); return true; } } this hrmodile.ts import { ngmodule } "@angular/core" import { routermodule} "@angular/router" import { hrroute } "../../app/route/hrroute" import { hrcomponent } "../../app/component/hrcomponent/hrcomponent" import { loginservice } "../../app/services/loginservice" @ngmodule({ imports: [routermodule.forchild(hrroute)], declarations: [hrcomponent], bootstrap: [hrcompone...

mysql - My php pdo class takes too much time to execute -

i made php database class pdo using project. simple. noticed 1 thing that, takes time execute. can tell me did wrong? here database class code class database{ public $error; private $db; private $dbhost = 'localhost'; private $dbname = 'support_database'; private $dbuser = 'root'; private $dbpass = ''; public $site_url = "http://localhost/support"; public function connect(){ try { $this->db = new pdo("mysql:host={$this->dbhost};dbname={$this->dbname}",$this->dbuser,$this->dbpass); $this->db->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) { // echo "connection error: ".$e->getmessage(); } } public function deleterecord($id){ $this->connect(); $statement = $this->db->prepare("delete officers_table id=?"); $...

python - SOS - Print values from one class to another -

Image
import sys pyqt5.qtwidgets import qwidget, qlabel, qapplication,qlcdnumber, qvboxlayout pyqt5.qtcore import (qcoreapplication, qobject, qrunnable, qthread, qthreadpool, pyqtsignal) pyqt5 import qtgui import time class scoreboard(qwidget): def __init__(self): super().__init__() self.initui() def initui(self): scorelcd = qlcdnumber(self) scorelcd.display(x) #how grab values in x below display here self.setgeometry(10, 50, 100, 100) self.setwindowtitle('timer') self.show() class countup(qthread): def run(self): x = 0 while 1: x = x + 1 time.sleep(1) print (x) #i want value in x printed in gui above def counter(): app = qapplication(sys.argv) ex = scoreboard() thread = countup() thread.finished.connect(app.exit) thread.start() sys.exit(app.exec_()) if __name__ == '__main__': counter() i have 2 different class...

java - JTextArea, JTextField, how to replace text from the caret to the left with another string -

i'm making text processing program, , want if user press 'a' ('a' demonstration, have list of special characters that), replace characters caret left string. i have tried "settext" method replaced moved caret , text component scrolled end, want caret not move anywhere else , text component not scroll end, how can code that(i overriding processkeyevent)? any appreciated. try use document filter: jtextarea textarea = new jtextarea(); ((abstractdocument) textarea.getdocument()).setdocumentfilter(new documentfilter() { @override public void replace(filterbypass fb, int offset, int length, string text, attributeset attrs) throws badlocationexception { if ("a".equals(text)) { text = "b"; } super.replace(fb, offset, length, text, attrs); } });

swift - My UIButton doesn't call the method targeted -

Image
i don't know wrong #selector : func iterate() { scrollview.subviews[0].subviews[0].addsubview(arrowbutton) arrowbutton.addtarget(self, action: #selector(self.pressbutton), for: .touchupinside) self.view.bringsubview(tofront: arrowbutton) } func pressbutton() { print("pouet pouet pouet") } override func viewdidload() { super.viewdidload() iterate() } (don't mind layout thing, i've removed constraints clarity's sake) when press button, nothing printed. i'm getting crazy #selector, how such important piece of development still using objc crap ? edit : uibutton on top of layer, or @ least that's xcode debugging tool saying (the button in right bottom corner) = i think error in line (scrollview.subviews[0].subviews[0].addsubview(arrowbutton)) may button added under @ view jsut check func iterate() { scrollview.subviews[0].subviews[0].addsubview(arrowbutton) arrowbutton.addtarget(self, action:...

android - Getting Error while display array-list from strings xml file on tab 1 -

i trying access array data string.xml file , display on tab 1. code working fine when working without tab fragment. when trying array list in tab 1 getting error in main activity have mentioned in main activity code line. have menu code working fine that's why didn't mention menu directory code. adding screenshot want display in tab 1. here tab1_fragment.xml code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="2dp"> <imageview android:id="@+id/profile_pic" android:layout_width="70dp" android:layout_height="70dp" android:contentdescription="desc" android:paddingl...

javascript - Adding child to parent in Jquery using variables -

i'm trying dynamically creating div inside div using jquery. when dump child nodes div1, shows text , strong. expecting 'div1' have main_div_elem child , main_div_elem have col_md_8_elem child. can me add col_md_8_elem child of main_div_elem , main_div_elem child of 'div1'? output of console log js function. nodelist [ #text "here", ] code: var id = 1; function trythis() { $( "#div1" ).append( "<strong>hello</strong>" ); var main_div_elem = $('<div /', {id : 'main_div_elem'.concat(id), "class" : "row"}); var col_md_8_elem = $('<div /', {id : 'col_md_8_elem'.concat(id), "class" : "col-md-8"}); main_div_elem.append(col_md_8_elem); $('#div'.concat(id)).append(main_div_elem); var children = document.getelementbyid("div1").childnodes; console.log(children); } trying achieve following htm code using jquery. <d...

python - Split an array in all possible combinations (not regular splitting) -

please read question before down voting. not find problem in other questions here. suppose have array, >>> import numpy np >>> array = np.linspace(1,4,4, dtype=np.int) >>> array array([1, 2, 3, 4]) i want function split array in possible parts, such that, no split : ([1,2,3,4]) split in 2 parts : ([1], [2,3,4]) ([1,2], [3,4]) ([1,2,3] ,[4]) split in 3 parts : ([1], [2], [3,4]) ([1,2]), [3], [4]) ([1], [2,3], [4]) split in len(array) parts : ([1],[2],[3],[4]) i know there np.split(array, r) , not give possible splits. e.g. np.split(array, 2) give, [array([0, 1]), array([2, 3])] as can see not need. how achieve need? you use itertools.combinations generate indices split inside loop on number of splits: >>> itertools import combinations >>> [np.split(array, idx) ... n_splits in range(5) ... idx in combinations(range(1, len(array)), n_splits)] [[array([1, 2, 3, 4])], [array([1]), array([2, 3,...

sql server - Using Excel VBA to run SQL query and getting error -

i new vba. run simple sql query vba code. found simple looking code task, keep getting error "automation error unspecified error 2147647259 (80004005)" stuck, please (user name , password masked). here code: sub download_standard_bom() dim cnn new adodb.connection dim rst new adodb.recordset dim connectionstring string dim strquery string connectionstring = "provider=sqloledb.1;password=13139797mmn;persist security info=true;user id=mpam;data source=172.20.84.15;use procedure prepare=1;auto translate=true;packet size=4096;use encryption data=false;tag column collation when possible=false;initial catalog=importhapoalim" cnn.open connectionstring cnn.commandtimeout = 900 strquery = "select max(cast(itra float)) [importhapoalim].[dbo].[minchali] deltaid = 275" rst.open strquery, cnn sheets(1).range("a2").copyfromrecordset rst end sub

session - How do I filter sanitize input in PHP? -

i have code below i'm trying filter sanitize form requires in $_session because need items page added onto page , displayed cart list. anyway i'm having trouble getting code filter anything. doesn't work not sure i've done wrong here?[code][1] if $_post data valid, customer details must added $_session , user forwarded new script called receipt.php <?php session_start(); if(isset($_session['cart'])) { $name = filter_input(input_session, 'name', filter_sanitize_string); $email = filter_input(input_session, 'email', filter_sanitize_email); $phone = filter_input(input_session, 'phone', filter_sanitize_int); $address = filter_input(input_session, 'address', filter_sanitize_string); } ?> so @ point need submit form testing purposes, heres code @ current time: session_start(); if(empty($_post['add']) === false ) { $name = filter_var($_post['name'], filter_sa...

asp.net mvc - SQL defined user authentication and MVC.net -

i work on project has predefined users inside oracle database. job write api (using c#.net mvc) on huge database. best practice user authentication in project? prefer in middle wares. currently don't know how find out users credentials , think it's impossible select them c# side, every time user request try make connection it's (user/password)input , if had no problem close , connect oracle admin credential, cause may have not in access of db-user (most of them have view access only) edit: wanted use mvc features (idk call) let "pattern" think impossible now. decided use 2 connection strings, 1 managing(with supervisor auth) , other user needs , let db manage permissions. if user credentials defined in oracle database place perform authentication - not in middle-ware. typically have database authentication function this: function authenticate_user (p_username varchar2, p_password varchar2) return boolean; when need authenticate user, call...

ios - Best way of working with ListView -

hey guys i´m in process of learning swift right , try program game. want show list items , different attributes these items. first have user choice of can select either food or toys or other stuff coming in future. here tried 1 viewcontroller , change stuff inside depending on choice. right have these items in array class. this: class fooddata { var name: string var description = "basic food" var owned = 0 var taste = 0 var price = 0 var water = 0 var image = "default.png" init(name: string){ self.name=name } } class toydata { var name: string var description = "basic item" var owned = 0 var price = 0 var joy = 0 var image = "default.png" init(name: string){ self.name=name } } i initialise these with: var foodload=[fooddata]() func loadfooddata(){ foodload.append(fooddata(name: "icecream")) foodload[0].description="very cold...

indicator - Slider w/thumbnail slider -

Image
i want use slider vertical indicator (in picture). does any1 know some? well, want here: http://flexslider.woothemes.com/thumbnail-slider.html slider w/thumbnail slider there isn't vertical indicator = switching menu, , i'm not able add there...so i'm trying find slider added. me please ? i mean, got code, , have no clue how add menu in picture in slider: <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>el gaucho</title> <meta name="viewport" content="width=device-width, inicial-scale=1"> <link rel="stylesheet" href="css/font-awesome.min.css"> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" type="text/css" href="css/flexslider.css"> <link rel="sty...

ruby on rails 5 - NoMethodError in Controller#show - Nested model -

it might newbie question can't head around it. rails telling me method not defined if can access in console. i'm missing obviously... here routes.rb file: rails.application.routes.draw root 'static_pages#home' resources :users resources :bodies end end here user model class user < applicationrecord has_many :bodies, dependent: :destroy end here body model class body < applicationrecord belongs_to :user end here bodies controller class bodiescontroller < applicationcontroller def new @user = user.find(params[:user_id]) @body = @user.bodies.new end def create @body = current_user.bodies.build(body_params) if @body.save redirect_to user_body_path(@body) else render 'new' end end def show @user = user.find(params[:user_id]) @body = @user.bodies(params[:id]) end def index @bodies = body.all end private def body_params params.requi...

Use of protected media properties in page ressources (TYPO3 8.7.4) -

Image
i have image file in page properties , can't find way use properties of file reference because protected. not every attribute must in debug. if filereference class can see there several getters different fields. in php do: $title = $myfilereference->gettitle(); $description = $myfilereference->getdescription(); in fluid do: {filereference.title} {filereference.description}

java - How to highlight an arraylist item when touched -

i'll appreciate if can me through this! what did 1) draw shape canvas in view class. 2) create array lists of random numbers. my problem i want when each item of array list touched, gets highlighted. i've searched lot can't find answer or question matched need! i'm new in android. here's part of code used creating array list of random numbers: import android.content.context; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.path; import android.util.attributeset; import android.view.motionevent; import android.view.view; import java.util.arraylist; public class yeknafareactivity_layout extends view { paint black_paintbrushstroke; path path = new path(); arraylist<integer> arraylist = new arraylist<>(); int rand; } and in constructor: public yeknafareactivity_layout(context context, attributeset atrs) { super(context, atrs); black_paintbrushstroke = ...

ios - declaring a global function across all views -

i have function eg. have across views in app. how go defining that. should function written. read somewhere here 1 possible solution define function uiviewcontroller extension so: extension uiviewcontroller { func displayalert(title:string, error:string, buttontext: string) { ... } } where should such procedure declared? thanks create new swift file , name like: uiviewcontroller+displayalert.swift in there can add code in question. extension uiviewcontroller { func displayalert(title:string, error:string, buttontext: string) { ... } } since extending uiviewcontroller, you'll able access function on subclasses of uiviewcontroller.

Python function decorator error -

i tried use function decorators, in example dooesn't work me, can give me solution ? def multiply_by_three(f): def decorator(): return f() * 3 return decorator @multiply_by_three def add(a, b): return + b print(add(1,2)) # returns (1 + 2) * 3 = 9 interpreter prints error: "typeerror: decorator() takes 0 positional arguments 2 given" when use decorator, function return decorator replaces old function. in other words, decorator function in multiply_by_three replaces add function. this means each functions signature's should match, including arguments. however, in code add takes 2 arguments while decorator takes none. need let decorator receive 2 arguments well. can using *args , **kwargs : def multiply_by_three(f): def decorator(*args, **kwargs): return f(*args, **kwargs) * 3 return decorator if decorate function , run it, can see works: @multiply_by_three def add(a, b): return + b print(add(1,2)...

C++: no match for call to '(concat) (std::string&)' -

i have been trying write c++ program concatenate strings taken input user using operator overloading on operator(+=). , have defined constructor initialize objects take string argument. still shows error error: no match call '(concat) (std::string&)'| here's code 3 files=> main.cpp #include <iostream> #include "concat.h" #include<string> using namespace std; int main() { concat ob[10]; concat result; int i; string ip; cout<<"enter strings upto 10 in different lines.. \n"; for(i=0;i<(sizeof(ob)/sizeof(ob[0]));i++){ cin>>ip; ob[i](ip); } while(i!=0){ result += ob[i++]; } cout<<result.input; } concat.h #ifndef concat_h #define concat_h #include<string> using namespace std; class concat { public: string input; concat(); concat(string ip); concat operator+=(concat ); }; #endif // concat_h concat.cpp #include <iostream> #include "concat.h" #incl...

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7' not resolve -

Image
this code of build.gradle(moudule app) apply plugin: 'com.android.application' android { compilesdkversion 25 buildtoolsversion "25.0.3" defaultconfig { applicationid "com.example.hn.myapplication" minsdkversion 14 targetsdkversion 25 versioncode 1 versionname "1.0" testinstrumentationrunner "android.support.test.runner.androidjunitrunner" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) androidtestcompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) //compile 'com.android.support.constraint:constraint-l...

api - Correct HTTP Response when resource changed -

i'm implementing rest web api .net core. 1 of action have in web api updating location of specific user.. [httpput("{username:username}/{regionname:regionname}", name = "updateuser")] public async task<iactionresult> updateuser([fromroute][required]string username, [fromroute][required]string regionname, [frombody][required]updateuserviewmodel user) { //..some code here } i.e. when operation finished, location of resource changed, if request in beginning was: request1: put "localhost:5000/controller/usernamehere/location1" , updated "location2" after request1 ends, new location request2: put"localhost:5000/controller/usernamehere/location2" , location in request1 irrelevant. my question : best practice response (status code, location) returned in case? thanks!

datetime - How to add one year to timestamp in Tarantool 1.8 using SQL? -

as see in documentation , i can add 1 year date using datetime() function: select datetime('2014-01-23 12:33:34', '1 year') result 2015-01-23 12:33:34 . but have timestamp in column (int value), example 1390466014 . when try add year timestamp using datetime() function obtain null instead of 1422005614 in result: select datetime(1390466014, '1 year') -- null how add 1 year timestamp obtain new timestamp? tarantool have functions working timestamps? your problem tarantool 1.8.1 storing , handling datetime strings. so, if want use unix time, thart explicitly, that: tarantool> select datetime(datetime(1390466014, 'unixepoch'), '1 year') --- - - ['2015-01-23 08:33:34'] ...

java - Multiple SessionAttributes into modelmap -

i pretty new spring, sorry if question may appear rather easy or obvious, trying answer bus wasn't able find it. question how use multiple sessionattributes , them map in 1 method? i.e. have @controller uses sessionattributes: @controller @sessionattributes({"name", "lastname", "birthdate"}) public class searchcontroller { @requestmapping(value = "/your-relatives") public string findrelatives(modelmap model) { string name = (string) model.get("name"); string lastname = (string) model.get("lastname"); string birthdate = (string) model.get("birthdate"); if (name.equals("john") && lastname.equals("johnny")) { return "yes"; } return "no"; } } but when trying return "yes" in case when if true, error - there unexpected error (type=internal server error, status=500). no message av...

swift - json swift4 how to set the struct? -

i want parse json http resource (it's router http mandatory). after set info.plist app security transport connection data 1st attempted: let sphdataaddress = "http://speedport.ip/data/status.json" let url = url(string: sphdataaddress)! let jsondata = try! data(contentsof: url) // ! testing reason , in real app guard let print("data \(jsondata)") // shows received data 5077bytes struct user { let vartype: string let varid: string let varvalue: company init?(dict: [string: any]) { guard let vartype = dict["vartype-data"] as? string, let varid = dict["valid-data"] as? string, let varvaluedict = dict["company"] as? [string: any], let varvalue = company(dict: varvaluedict) else { return nil } self.vartype = vartype self.varid = varid self.varvalue = varvalue } struct company { ...