Created
September 2, 2013 00:15
-
-
Save ethereal-engineer/6408190 to your computer and use it in GitHub Desktop.
Forked fuckingblocksyntax.com optimised for landscape PDF output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>How Do I Declare A Block in Objective-C?</title> | |
<style> | |
body { | |
background-color: #FFFFFF; | |
color: #83948F; | |
font-family: Lucida Grande, sans-serif; | |
font-size: 16px; | |
padding: 20px; | |
padding-bottom: 0; | |
} | |
strong { | |
color: #0088D9; | |
} | |
h1 { | |
font-size: 28px; | |
margin-bottom: 1.0em; | |
text-align: center; | |
} | |
h2 { | |
font-weight: normal; | |
} | |
.return { | |
color: #00A69A; | |
} | |
.name { | |
color: #BC8800; | |
} | |
.parameter-types, .parameters { | |
color: #7C9F00; | |
} | |
code { | |
display: block; | |
font-family: Monaco, Menlo; | |
font-size: 16px; | |
margin-bottom: 2.0em; | |
margin-left: 20px; | |
margin-top: 1.5em; | |
} | |
footer { | |
font-size: 10px; | |
margin-top: 40px; | |
opacity: 0.4; | |
text-align: right; | |
} | |
footer a { | |
color: #0088D9; | |
text-decoration: none; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>How Do I Declare A Block in Objective-C?</h1> | |
<div> | |
<h2>As a <strong>local variable</strong>:</h2> | |
<code> | |
<span class='return'>returnType</span> (^<span class='name'>blockName</span>)(<span class='parameter-types'>parameterTypes</span>) = ^<span class='return'>returnType</span>(<span class='parameters'>parameters</span>) {...}; | |
</code> | |
</div> | |
<div> | |
<h2>As a <strong>property</strong>:</h2> | |
<code> | |
@property (nonatomic, copy) <span class='return'>returnType</span> (^<span class='name'>blockName</span>)(<span class='parameter-types'>parameterTypes</span>); | |
</code> | |
</div> | |
<div> | |
<h2>As a <strong>method parameter</strong>:</h2> | |
<code> | |
- (void)someMethodThatTakesABlock:(<span class='return'>returnType</span> (^)(<span class='parameter-types'>parameterTypes</span>))<span class='name'>blockName</span> {...} | |
</code> | |
</div> | |
<div> | |
<h2>As an <strong>argument to a method call</strong>:</h2> | |
<code> | |
[someObject someMethodThatTakesABlock: ^<span class='return'>returnType</span> (<span class='parameters'>parameters</span>) {...}]; | |
</code> | |
</div> | |
<div> | |
<h2>As a <strong>typedef</strong>:</h2> | |
<code> | |
typedef <span class='return'>returnType</span> (^<span class='name'>TypeName</span>)(<span class='parameter-types'>parameterTypes</span>);<br/> | |
<span class='name'>TypeName</span> blockName = ^(<span class='parameters'>parameters</span>) {...} | |
</code> | |
</div> | |
<footer>By <a href="http://lazerwalker.com">Mike Walker</a>, who has a very bad memory for this sort of thing.</footer> | |
<script> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-43658906-1', 'fuckingblocksyntax.com'); | |
ga('send', 'pageview'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment