Friday, July 31, 2009

[OSX] How to turn off beep sound in Terminal


Open Prefereneces of 'Terminal' menu.

Go to 'advanced' tab and uncheck bell item.

That's all :)


Friday, July 17, 2009

[iPhone] save image to Photo Library.

Hello, everyone.

Today, I'll see how I can save an Image to Photo Library.

Call 'UIImageWriteToSavedPhotoAlubm' method in UIImagePickerController.h with your 'UIImage object'.

That's all :) It's so easy, isn't it ?

Let me see the declaration of this method.

UIKIT_EXTERN void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);



This method also adapt selector to inform complete ( or error).

A selector should be formed like....

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;

Have nice day, and wish your happiness :)


[iPhone] add info button to UIToolBar


How can I insert 'info button' to UIToolBar ?

You should use 'UIBarButtonItem' to add some item to UIToolBar.

In example you can create it like below code.

UIBarButtonItem *actionItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];


You can use UIBarButtonSystemItem* but there is no info button.

I noticed there is other init method named 'initWithCustomView'
You can create customized BarButtonItem with it.

I created info button with UIButton like below code.

UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];


[button addTarget:self action:@selector(infoPressed:) forControlEvents:UIControlEventTouchUpInside];


UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];

Let's do it !! :)



Sunday, July 5, 2009

[iPhone - cocos2d] execute N-actions at once.

Is there any way to execute N-actions at once ?

The answer is 'Yes, there is ".

There is a Class named 'Spawn' in Cocos2d library.

Let's see the Documentation of 'Spawn' Class.

@interface Spawn : IntervalAction
{
FiniteTimeAction *one;
FiniteTimeAction *two;
}

'Spawn' is an one of sub Class of 'IntervalAction'.
And basically it can have only 2 action.

But, as you can see, there is a class method names "actions:".
That method support N-Actions. How is it possible ?
The answer is simple, Spawn object can have other Spawn object as its property.

Let me show some example.

Action *action = [Spawn actions:[RotateBy actionWithDuration:aValue angle:180], [FadeIn actionWithDuration:aValue], [ScaleTo actionWithDuration:aValue scale:1.5],nil];

Spawn have 'RotateBy' and ' FadeIn' and 'ScaleTo'

And those actions will be executed at a time.

Enjoy your development :)