在数据结构中,当分配以下 head = head.next 时,我相信头然后指向下一个元素。 但是,如果我写道: head.next = head ,操作是否仍然相同?提前谢谢。
答案 0 :(得分:7)
typedef void (^HttpCompletionBlock) (NSString *token, NSError *error);
-(void) sendLogin :(HttpCompletionBlock)completionHandler
{
NSString *string = @"https://myserver/customer_authentication";
NSDictionary *parameters = @{@"member_id": @"1234", @"access_code": @"password", @"device_id":@"874627864"};
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:string parameters:parameters progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
if (responseObject[@"secret_token"])
{
NSLog(@"Secret is= %@",responseObject[@"secret_token"]);
//Here I needd to send back token number????
return completionHandler(responseObject[@"secret_token"],nil);
}
}
failure:^(NSURLSessionTask *operation, NSError *error)
{
NSLog(@"Error: %@", error);
return completionHandler(nil,error);
}];
}
- (IBAction)bankLoginPressed:(id)sender
{
[registerUser sendLogin:^(NSString *token, NSError *error){
if(error == nil)
{
NSLog(@"access code == %@ ",token);
}
else
{
NSLog(@"Error == %@ ",error);
}
}];
}
会创建一个包含单个元素的循环列表,因为列表的function calculateThroughput(json){
var flowsObj = json.flows;
var throughputSum = 0;
var noOfSamples = 0;
for(noOfFlows in flowsObj){
var resultObj = flowsObj[noOfFlows].results;
for(noOfResults in resultObj){
if(resultObj[noOfResults].protocol == "TCP"){
throughputSum += resultObj[noOfResults].throughput_kbps;
noOfSamples++;
}
}
}
return (throughputSum/noOfSamples);
};
会指向自身。