Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am trying to declare a var in which then I will set with some kind of class depending on a certain condition, so :
var tmodule
if..
tmodule=ModuleInput(frame: CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height))
if..
tmodule=ModuleOut(frame: CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height))
I get an error on the declaration , and I can't find the right way to do it.
tmodule=tmodule:ModuleInput=ModuleInput(frame: CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height))
This doesn't make any sense. Perhaps you meant:
var tmodule: ModuleInput //type annotation necessary here
//...
let frameSize = self.view.frame.size
tmodule = ModuleInput(frame: CGRectMake(0, 0, frameSize.width, frameSize.height)) //type inferred here
tmodule=tmodule:ModuleInput=ModuleInput(....
should be
tmodule = ModuleInput(....
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
I declared one variable in dart as follows-
var Latitude;
void GetCLocation() async {
Latitude=1;
}
main(){
print(Latitude);
}
The problem is that the output is not coming out to be 1, but it is coming out to be null. What am I doing wrong?
Do this instead, you should call the function for it to be assign:
void main() {
var Latitude;
void GetCLocation() async {
Latitude=1;
}
GetCLocation();
print(Latitude);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need call three API one after another in same view controller.these three API called after every 10 min. And the first api call's response use as parameter to third api call.
func a(){}
func b(){}
Func c(){}
Is there a way to call these api synchronously.
I want to call first func a then b and c.
How can i can implement the logic ? Thanks in advance.
Write three functions, call1(), call2(), and call3(). Have each one take a completion handler:
That might look something like this:
typealias networkCompletion = (Data) -> Void
func call1(callCompletion: networkCompletion) {
//set up a URLSessionDataTask in `myDataTask`
myDataTask.run() { result in
switch result
{
case success(data):
callCompletion(result.data)
}
case error:
//error handling
{
}
//And so on for call2 and call3...
//Then have the completion handler for call1 call call3,
//and the completion handler for call2 call call3:
call1() { call1Data in
call2(call1Data) { call2Data in
call3(call2Data) { call3Data in
//Call3 is complete. You've got your final data in call3Data
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How to get an object reference in Scala? I would like to compare those references to see if it's a new or old object which is being used.
var objArr: ArrayBuffer[someObj] = new ArrayBuffer[someObj](0)
// fill array
objArr(0) // how to get the internal reference of that array object and not the content of it?
Any help is highly appreciated!
Actually objArr(0) seems to be what you want
class MyClass
val x = new MyClass
var objArr: ArrayBuffer[MyClass] = ArrayBuffer(x)
objArr(0) eq x // true
objArr(0) eq new MyClass // false
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to write an if statement that tests two conditions in Groovy, but the language does not appear to support && or &. I'd like to avoid using a nested if statement if possible for this. How can I accomplish this?
Yes groove support the logical-and operator('&&') and bitwise-and operator('&').
class Example {
static void main(String[] args) {
// Initializing a local variable
int a = 2
//Check for the boolean condition
if (a<100 && a>0) {
//If the condition is true print the following statement
println("The value is less than 100");
} else {
//If the condition is false print the following statement
println("The value is greater than 100");
}
}
}
but it is not supporting '&&' or '&'
That's incorrect. Both the logical AND (&&) and the bitwise and (&) work in groovy. See the list of operators in the official documentation.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a class which declare the dictionary tags
This is declare in class FirstClass
-(NSDictionary *)getTags{
return tags;
}
At unit testing
i created FirstClassTest class of ocUnit Testing
included #import "FirstClass.h"
-(void)setUP{
[super setUp];
// Allocations the class
_firstClass = [[FirstClass alloc]init];
}
-(void)tearDown{
_firstClass =nil;
[super tearDown];
}
-(void)testDictationGetValue{
// Need to write Unit test for that class
[_firstClass getTags];
}
This is my first time writing unit testing!
Can any one guide me to write proper unit test cases
#All Thanks in advance
First, it looks like you’re writing a plain getter. That doesn’t make much sense in modern Objective-C: if you just want to return a pointer to an instance variable, use a synthesized getter (and drop the get prefix).
Second, what do you want to test here? If you just want to test that the getter really does return some dictionary, then the test is essentially useless. Maybe the tags are calculated according to some other values? Then set up those values and check that the tags dictionary is computed correctly. Never write test just for their own sake.
IT should be!!!
-(void)testDictationGetValue
{
_firstClass = nil;
_firstClass = [[FirstClass alloc] init];
NSDictionary *t_dictionary = [_firstClass getTags];
if (t_dictionary == nil) {
STAssertNil(nil, #"TestFailed return value is nil");
}
else {
STAssertNotNil(t_dictionary, #"Retrun value");
}
}