Archive for December, 2010

【食記】三家吃過不錯的燒臘店比一比

Friday, December 31st, 2010

旺旺燒臘

這家位於永春捷運站附近的夜市裡,是目前我吃過覺得最好吃的燒臘店。老闆是香港人,店內常常可以看到香港人來吃。燒臘非常道地,跟我在香港吃到的燒臘名店差不多。以前租房子在東湖時騎車下班經過時,常常會來吃。除了一般都會有的三寶飯,這裡還提供”五寶飯”,一次就可吃到 油雞、燒鴨、叉燒、燒肉、香腸 五種,超讚! 份量很多。這五種裡面我覺得最好吃的是油雞,淋上蔥油後配飯吃超讚!

油雞&燒鴨

燒肉近拍

好味燒臘

這家位於台北車站附近,是網路上查到很多人推薦的燒臘店,便宜又好吃。尤其是燒鴨的肉非常香,咬下去會有肉汁溢出,非常好吃!! 另外叉燒也不錯,蠻有彈性,味道也剛好。除了肉以外,他的配菜也比一般的燒臘店好,不是那種爛爛的配菜。

特寫

鏞記燒臘

這家位於石牌就在我們家附近,搬來石牌這麼久了,一直沒去試過,真是不像話 ~”~。這是我家夫人上網在查石牌附近好吃的店時,不少人推薦的,算是石牌附近比較像樣的燒臘店了。常常騎車會路過,但是一直沒有走進去買過,因為店看起來真的不太起眼。老闆也是香港人,切工很利落,很像大俠… :shock: 。他們家的叉燒,肉還蠻有彈性,味道剛剛好不會太甜,其他就比較普通一點。配菜有8種可以自己選3種,不過肉的份量比起來好像少了點…

selector in Objective-C

Tuesday, December 28th, 2010

selector在Objective-C裡面,通常被拿來當作callback function使用。以下是網路上看來的,先記起來,以免日後要找時忘記。

SEL is a type that represents a selector in Objective-C. The @selector() keyword returns a SEL that you describe. It’s not a function pointer and you can’t pass it any objects or references of any kind. For each variable in the selector (method), you have to represent that in the call to @selector. For example:

-(void)methodWithNoArguments;
SEL noArgumentSelector = @selector(methodWithNoArguments);

-(void)methodWithOneArgument:(id)argument;
SEL oneArgumentSelector = @selector(methodWithOneArgument:); // notice the colon here

-(void)methodWIthTwoArguments:(id)argumentOne and:(id)argumentTwo;
SEL twoArgumentSelector = @selector(methodWithTwoArguments:and:); // notice the argument names are omitted

Selectors are generally passed to delegate methods and to callbacks to specify which method should be called on a specific object during a callback. For instance, when you create a timer, the callback method is specifically defined as:

-(void)someMethod:(NSTimer*)timer;

So when you schedule the timer you would use @selector to specify which method on your object will actually be responsible for the callback:

@implementation MyObject

-(void)myTimerCallback:(NSTimer*)timer
{
    // do some computations
    if( timerShouldEnd ) {
      [timer invalidate];
    }
}

@end

// ...

int main(int argc, const char **argv)
{
    // do setup stuff
    MyObject* obj = [[MyObject alloc] init];
    SEL mySelector = @selector(myTimerCallback:);
    [NSTimer scheduleTimerWithTimeInterval:30.0 target:obj selector:mySelector userInfo:nil repeats:YES];
    // do some tear-down
    return 0;
}

In this case you are specifying that the object obj be messaged with myTimerCallback every 30 seconds.

假如一個function在該做的事完成後要執行selector callback,可以類似下面這樣寫

-(void) someMethod:(id)handler selector:(SEL)selector {
    // some codes here...

    // execute callback function
    if( handler != nil && selector != nil && [handler respondsToSelector:selector] ) {
        [handler performSelector:selector];
    }
}

Reference:
http://stackoverflow.com/questions/297680/how-do-sel-and-selector-work-in-iphone-sdk

【iPhone開發】如何做一個Username/Password彈跳視窗(UIAlertView)?

Tuesday, December 28th, 2010

  1. 首先,你要初始化一個UIAlertView物件。然後你必須將message的參數值設為@”\n\n\n”,這是用來多留幾行空白以便擺放輸入框欄位。
  2. 建立兩個UITextField物件,將他們加至UIAlertView裡成為subview。別忘了設定輸入框的背景色(setBackgroundColor)、預設文字(setPlaceholder)、安全表示(setSecureTextEntry,輸入文字時會變成星號,用於密碼欄)。
  3. 最後,在呈現UIAlertView時,在垂直位移加上一點Shift值並且有需要的話將之設定為FirstResponder。

Source Code:

UITextField *textField;
UITextField *textField2;

UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Username and password"
                                                 message:@"\n\n\n" // IMPORTANT
                                                delegate:nil
                                       cancelButtonTitle:@"Cancel"
                                       otherButtonTitles:@"Enter", nil];

textField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];
[textField setBackgroundColor:[UIColor whiteColor]];
[textField setPlaceholder:@"username"];
[prompt addSubview:textField];

textField2 = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 85.0, 260.0, 25.0)];
[textField2 setBackgroundColor:[UIColor whiteColor]];
[textField2 setPlaceholder:@"password"];
[textField2 setSecureTextEntry:YES];
[prompt addSubview:textField2];

// set place
[prompt setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];
[prompt show];
[prompt release];

// set cursor and show keyboard
[textField becomeFirstResponder];

Reference:
http://iphone-dev-tips.alterplay.com/2009/12/username-and-password-uitextfields-in.html