Tag Archives: objective c

Animate A Fade-Out Of A NSWindow With Objective-C

Animate A Fade-Out Of A NSWindow With Objective-C – (void)fadeOutWindow:(NSWindow*)window{ float alpha = 1.0; [window setAlphaValue:alpha]; [window makeKeyAndOrderFront:self]; for (int x = 0; x < 10; x++) { alpha -= 0.1; [window setAlphaValue:alpha]; [NSThread sleepForTimeInterval:0.020]; } } http://codesnippets.joyent.com/posts/show/12745

Posted in Objective-C | Also tagged , , , , , , , | Leave a comment

(Objective C) Importing Header Files

In your header, @class suffices 90% of the time.

Posted in Objective-C | Also tagged , , , , , , , | Leave a comment

(Objective C) Playing and Stopping Sound Effect in Cocos2d

This is how you play and stop sound effects in cocos2d

Posted in Objective-C | Also tagged , , , , | Leave a comment

(Objective C) How to find the distance between two CG points

Distance between p1 and p2: CGFloat xDist = (p2.x – p1.x); CGFloat yDist = (p2.y – p1.y); CGFloat distance = sqrt((xDist * xDist) + (yDist * yDist)); Background: Pythagorean theorem Edit: if you only need to calculate if the distance between the points increases or decreases, you can omit the sqrt() which will make it [...]

Posted in Objective-C | Also tagged , , , , | Leave a comment

(Objective C) Checking If You App Has Been Run Before

Do you need you app to do something when it is first run on a certain computer? Do you need to know if it has been run before? Enter the following code into your Application Delegate. This code creates a BOOL that is created when the app is run. The if-else statement reads the value [...]

Posted in Objective-C | Also tagged , , , , | Leave a comment

(Objective C) Play a video in full screen

1. include MediaPlayer framework in the project 2. in the view controller header file, #import 3. declare the player instance in the controller header file: MPMoviePlayerViewController *playerViewController;

Posted in Objective-C | Also tagged , , , , | 3 Comments

(Objective C) Add UIToolBar on top of Keyboard

It should go in textFieldShouldBeginEditing: delegate

Posted in Objective-C | Also tagged , , , , | Leave a comment