objective-c中的@()是什么意思?

时间:2015-09-01 11:02:29

标签: objective-c

我在Objective-c代码中看到<div id="output"></div> <div id="log"></div> <script type="text/javascript"> // handles the click event for link 1, sends the query var times=0; function getOutput() { setInterval(function(){ getRequest( 'prova1.php', // URL for the PHP file drawOutput, // handle successful request drawError // handle error ); return false; },3000); } // handles drawing an error message function drawError() { var container = document.getElementById('output'); container.innerHTML = 'Bummer: there was an error!'; } // handles the response, adds the html function drawOutput(responseText) { var container = document.getElementById('output'); container.innerHTML = responseText; } function getRequest(url, success, error) { times++; var req = false; try{ // most browsers req = new XMLHttpRequest(); } catch (e){ // IE try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { // try an older version try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { return false; } } } if (!req) return false; if (typeof success != 'function') success = function () {}; if (typeof error!= 'function') error = function () {}; req.onreadystatechange = function(){ if(req.readyState == 4) { return req.status === 200 ? success(req.responseText) : error(req.status); } } req.open("GET", url, true); req.send(null); var log = document.getElementById('log'); log.innerHTML = 'Loop:'+times; return req; } getOutput(); </script> ,我猜它是一种语法糖,但它究竟意味着什么?

1 个答案:

答案 0 :(得分:6)

@(表达式)

动态评估盒装表达式并根据其值返回适当的对象文字(即const char *的NSString,int的NSNumber等)。这也是使用枚举值的数字文字的指定方法。

compiler-directives