은 내가 전화 할 때 다음이블록의 계산 시간을 계산하는 방법은?
#define TOOLS_COMPUTE_TIME(op) [Tools computeTimeWithName:__PRETTY_FUNCTION__ block:(op)]
+(void)computeTimeWithName:(NSString *) caller block:(void (^)())block
{
NSDate * currentTime = [NSDate date];
block();
DLog(@"Time Running is: %f", [[NSDate date] timeIntervalSinceDate:currentTime]);
DLog(@"Caller : %@", caller);
}
과 같은 TOOLS_COMPUTE_TIME을 정의입니다 : "매크로"TOOLS_COMPUTE_TIME처럼 ..
TOOLS_COMPUTE_TIME(^{
});
[Tools computeTimeWithName:ThisFunction block:^{
//I want to move this blog on top
NSString * urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=csv",[BNUtilitiesQuick UtilitiesQuick].currentAnchor.coordinate.latitude,[BNUtilitiesQuick UtilitiesQuick].currentAnchor.coordinate.longitude];
NSURL * Url= [NSURL URLWithString:urlString];
NSString * result = [NSString stringWithContentsOfURL:Url encoding:NSASCIIStringEncoding error:nil];
NSArray *lines = [result componentsSeparatedByString:@","];
locationString =[NSString stringWithFormat:@"%@\"",[lines objectAtIndex:2]];
}];
여전히 많은 오류를 가지고 있어요는 "4 개 인수를 전달하지만, 단지 1 소요" 그 코드와 같은
뭔가 많은 인수를 가지고,하지만 난 블록처럼 그 코드를 통과 한 인수
어떤 생각 하나는 그것을 해결하는 데 도움이 될 수 있습니까?
에 다른 오류가있는 것 같습니다. PRETTY_FUNCTION NSString *이 아닙니다. 뭐?
하하, 방금 귀하의 문제가 실제로 [내 잘못]임을 알았습니다 (http://stackoverflow.com/questions/7411027/how-to-nslog-calling-function/7411041#7411041). 아마도 varargs 매크로를 사용하기 위해 그 대답을 편집해야합니다. –
#define TOOLS_COMPUTE_TIME (...) [도구 computeTimeWithName : [NSString stringWithFormat : @ "% s", __ PRETTY_FUNCTION__] 블록 : (__ VA_ARGS__)]을 사용합니다. –