[categories] [index] [all (531)] [latest]
\usepackage{color}
\usepackage{listings}
\definecolor{pink} {rgb}{0.67, 0.05, 0.57} % keywords
\definecolor{red} {rgb}{0.87, 0.20, 0.00} % strings
\definecolor{green} {rgb}{0.00, 0.47, 0.00} % comments
\definecolor{violet}{rgb}{0.41, 0.12, 0.61} % classes
\definecolor{blue} {rgb}{0.21, 0.00, 0.44} % functions
\definecolor{brown} {rgb}{0.39, 0.22, 0.13} % brown
\lstdefinelanguage{Objective-C 2.0}[Objective]{C} {
morekeywords={id, Class, SEL, IMP, BOOL, nil, Nil, NO, YES,
oneway, in, out, inout, bycopy, byref,
self, super, _cmd,
@required, @optional,
@try, @throw, @catch, @finally,
@synchronized, @property, @synthesize, @dynamic},
moredelim=[s][color{red}]{@"}{"},
moredelim=[s][color{red}]{<}{>}
}
\lstdefinestyle{Xcode} {
language = Objective-C 2.0,
basicstyle = footnotesizettfamily,
identifierstyle = color{black},
commentstyle = color{green},
keywordstyle = color{pink},
stringstyle = color{red},
directivestyle = color{brown},
extendedchars = true,
tabsize = 4,
showspaces = false,
showstringspaces = false,
breakautoindent = true,
flexiblecolumns = true,
keepspaces = true,
stepnumber = 0,
xleftmargin = 0pt}
\lstset{
style = Xcode,
caption=lstname,
breaklines=false,
frame=single
}
Use it like this:
\begin{lstlisting}[name=Sample code, label=SampleCode]
NSLog(@"hello");
\end{lstlisting}
List the listings:
\lstlistoflistings