argument-passing

Passing a touch event to all subviews of a View Controller

本秂侑毒 提交于 2019-12-03 16:35:46
I have a view controller which creates multiple subviews on top of it. All subviews and the view controller accept touches. How can i communicate the touch point information to all the subviews on the screen? Keep in mind that each subview covers the entire screen so after a few additions its a bit like pages in a book. That is, any subviews below the top subview can't be touched directly by the user. I have tried using [self.nextResponder touchesBegan:touches withEvent:event] however this only sends the touch information from the top subview to the superview bypassing all other subviews on

Pass and access structures using objective-c

无人久伴 提交于 2019-12-03 15:59:30
I want to know how to pass structures to another function and subsequently access that structure in the called function. I'm developing for the iPhone and the reason I'm using structs is so that I can eventually pass data as structs to a server being built in C. Here's the structure: struct userInfo{ NSString *firstName; NSString *lastName; NSString *username; NSString *email; NSString *ipAddress; double latitude; double longitude; }; Here I'm simply fetching some user inputed data along with some CoreLocation data and the iPhone's IP Address: - (IBAction)joinButton { struct userInfo localUser

Is there a Scala equivalent of the Python list unpack (a.k.a. “*”) operator?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 15:00:48
问题 In Python, we have the star (or "*" or "unpack") operator, that allows us to unpack a list for convenient use in passing positional arguments. For example: range(3, 6) args = [3, 6] # invokes range(3, 6) range(*args) In this particular example, it doesn't save much typing, since range only takes two arguments. But you can imagine that if there were more arguments to range , or if args was read from an input source, returned from another function, etc. then this could come in handy. In Scala,

x86 calling convention: should arguments passed by stack be read-only?

五迷三道 提交于 2019-12-03 11:36:10
问题 It seems state-of-art compilers treat arguments passed by stack as read-only. Note that in the x86 calling convention, the caller pushes arguments onto the stack and the callee uses the arguments in the stack. For example, the following C code: extern int goo(int *x); int foo(int x, int y) { goo(&x); return x; } is compiled by clang -O3 -c g.c -S -m32 in OS X 10.10 into: .section __TEXT,__text,regular,pure_instructions .macosx_version_min 10, 10 .globl _foo .align 4, 0x90 _foo: ## @foo ## BB

Order of default and non-default arguments

末鹿安然 提交于 2019-12-03 11:34:06
问题 In Python, I understand that default arguments come at the end and that non-default arguments cannot follow a default argument. That is fine. Like for example: >>> def foo(x=0, y): return x, y SyntaxError: non-default argument follows default argument That is OK as expected. However, what about the case when I want that the first argument should be a default one ? Like for example, as is apparent from the above code, x has to be the first argument and it should have a default value of 0. Is

How can I pass command-line arguments via file association in Vista 64?

大兔子大兔子 提交于 2019-12-03 08:21:34
How can one pass command line arguments via file association in Vista 64? I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple test, I wrote the following (foo.pl): #!/usr/bin/perl -w use strict; my $num_args = $#ARGV + 1; print "${num_args} arguments read\n"; print "$^X\n" # to see what was being used Running "foo.pl 1 2 3" undesirably yielded: 0 arguments read C:\strawberry\perl\bin\perl.exe Running "perl foo.pl 1 2 3" expectedly yielded: 3 arguments read C:\strawberry\perl

Understanding an uncommon argument to main

混江龙づ霸主 提交于 2019-12-03 07:07:37
问题 The following question was given in a college programming contest. We were asked to guess the output and/or explain its working. Needless to say, none of us succeeded. main(_){write(read(0,&_,1)&&main());} Some short Googling led me to this exact question, asked in codegolf.stackexchange.com : https://codegolf.stackexchange.com/a/1336/4085 There, its explained what it does : Reverse stdin and place on stdout , but not how . I also found some help in this question : Three arguments to main,

Efficient memoization in Python

白昼怎懂夜的黑 提交于 2019-12-03 07:04:14
问题 I have some task to solve and the most important part at the moment is to make the script as time-efficient as possible. One of the elements I am trying to optimize is memoization within one of the functions. So my question is: Which of the following 3-4 methods is the most efficient / fastest method of implementing memoization in Python? I have provided code only as an example - if one of the methods is more efficient, but not in the case I mentioned, please share what you know. Solution 1 -

pass arguments between shell scripts but retain quotes

自古美人都是妖i 提交于 2019-12-03 05:36:21
问题 How do I pass all the arguments of one shell script into another? I have tried $*, but as I expected, that does not work if you have quoted arguments. Example: $ cat script1.sh #! /bin/sh ./script2.sh $* $ cat script2.sh #! /bin/sh echo $1 echo $2 echo $3 $ script1.sh apple "pear orange" banana apple pear orange I want it to print out: apple pear orange banana 回答1: Use "$@" instead of $* to preserve the quotes: ./script2.sh "$@" More info: http://tldp.org/LDP/abs/html/internalvariables.html $

Is there a Scala equivalent of the Python list unpack (a.k.a. “*”) operator?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 04:38:19
In Python, we have the star (or "*" or "unpack") operator, that allows us to unpack a list for convenient use in passing positional arguments. For example: range(3, 6) args = [3, 6] # invokes range(3, 6) range(*args) In this particular example, it doesn't save much typing, since range only takes two arguments. But you can imagine that if there were more arguments to range , or if args was read from an input source, returned from another function, etc. then this could come in handy. In Scala, I haven't been able to find an equivalent. Consider the following commands run in a Scala interactive