[TT/TC 플러그인] SyntaxHighlighter 1.3 – Google Code Prettify

[code]#!/bin/bash
# Fibonacci numbers
# Writes an infinite series to stdout, one entry per line

function fib() { 
  local a=1
  local b=1
  while true ; do
    echo $a
    local tmp=$a
    a=$(( $a + $b ))
    b=$tmp
  done
}

# output the 10th element of the series and halt
fib | head -10 | tail -1[/code]
기존에 만들어서 배포하였던 Syntax Highlighter 1.2.1 버젼을 대폭 업그레이드 하였습니다.

기존의 설명을 보실려면 [이곳]을 눌러보시면 상세한 내용이 있으니 참고하시기 바랍니다.

Visual Basic, Haskell, CSS, WikiText, MXML, Object-C, F#, OCAML, SQL 과 같은 언어들의 처리 핸들러가 추가되었습니다.

실제로 최신의 Google Code Pretify 엔진으로 업데이트 하였습니다.

또한 복사가 제대로 안되던 문제를 해결하였습니다. 디자인을 심플하게 변경하였습니다.

CSS를 조금만 아신다면 pretify.css 파일의 내용을 수정하시어 디자인을 수정하실 수 있습니다.

지원 언어의 하이라이팅 테스트를 해보고 싶으시면 [이곳]을 방문하셔서 보시면 됩니다. 시간이 조금 걸립니다.

1027095019.zip

[iPhone] Object-C : Fast Enumeration

Object-C 2.0에 들어 열거형 변수를 좀더 효과적이고 안전하게 사용하기 위해 for 문법이 업그레이드 되었습니다.

이것을 보고 이름하여 Fast Enumeration 이라고 부르는군요. PHP나 Ruby등에서 볼수 있는 foreach와 같은 기능입니다.

일반적인 C에서의 구현에 비해서 매우 편리하게 반복문을 작성할 수 있습니다. 문법은 다음과 같습니다.

// one
for ( Type newVariable in expression ) { statements }

// two
Type existingItem;
for ( existingItem in expression ) { statements }

사용 예제를 보시면 바로 이해가 되실 것입니다. 예제를 보실까요.

NSArray

NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil];
for (NSString *element in array) {
    NSLog(@"element: %@", element);
}
// element: One
// element: Two
// element: Three
// element: Four

NSDictionary

NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                           @"quattuor", @"four", @"quinque", @"five", @"sex", @"six", nil];
NSString *key;
for (key in dictionary) {
    NSLog(@"English: %@, Latin: %@", key, [dictionary valueForKey:key]);
}
// English: four, Latin: quattuor
// English: five, Latin: quinque
// English: six, Latin: sex

NSArray – nextObject

NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil];
NSEnumerator *enumerator = [array reverseObjectEnumerator];
for (NSString *element in enumerator) {
    if ([element isEqualToString:@"Three"]) {
        break;
    }
}
NSString *next = [enumerator nextObject];
// next = "Two"

안타깝게도 인덱스가 필요하다면 따로 제공하는것이 없어 다음과 같이 사용하셔야 합니다.

NSArray *array = /* assume this exists */;
NSUInteger index = 0;
for (id element in array) {
    NSLog(@"Element at index %u is: %@", element);
    index++;
}

예제만으로도 충분히 만족감을 주는 간단한 내용이었습니다.