Tag Archives: objective-c

Play a movie in fullscreen (Objective-C)

Hi, In reply to http://snipd.net/objective-c-play-a-video-in-full-screen#comment-290 . The following snippets show how to play a movie in fullscreen.

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

(Objective C) Enable UIButton inside UIImageView

When you add a UIButton as a subview to UIImageView, it will not correspond to touch events automatically, UIImageView’s userinteraction property needs to be set

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

Scaling an image in Objective-C (Cocoa Framework)

The UIImage class can be used to represent an image. The following snippet scales an image according to a size which is provided with a CGSize parameter. + (UIImage *)scale:(UIImage *)image toSize:(CGSize)size { UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; }

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

Run a method in a separate thread in Objective-C (Cocoa Framework)

In some situations, performing operations in a single thread can cause an application to appear as if it is hanging. For example, when searching with autocomplete enabled within a large amount of records in a database . The user is typing and the application is performing a computationally complex operation at the same time (searching [...]

Posted in Objective-C | Also tagged , , , , , , , , , , | 1 Comment

Date Formatting in Objective-C (Cocoa Framework)

Date Formatting in Objective-C //Format Date NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat: @"yyyy-MM-dd HH:mm:ss zzz"]; // 2009-02-01 19:50:41 PST NSString *dateString = [dateFormat stringFromDate: [scoreData objectForKey: @"date"]]; http://codesnippets.joyent.com/posts/show/12740

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

Get Device GUID from iPhone

Get Device GUID from iPhone UIDevice *device = [UIDevice currentDevice]; NSString *uniqueIdentifier = [device uniqueIdentifier]; http://codesnippets.joyent.com/posts/show/12741

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

(Objective-C) Basic NSTableView Control Functions (Cocoa Framework)

Basic NSTableView Control Functions

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) Global Constants II

Equality can be tested with: stringInstance == MyFirstConstant, not necessary to do a string comparison (isEqualToString)

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

(Objective C) Play a sound file

// Play sound //To load sound file. +(void) playSound:(NSString *)fileName { NSString *path = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] resourcePath],fileName];</code> <code>//declare a system sound id SystemSoundID soundID; //Get a URL for the sound file NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; //Use audio sevices to create the sound AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); </code> <code> //Use audio services to play the [...]

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