New Objective-C literal syntax (Apple LLVM 4.0 compiler in the Xcode 4.4 beta)

Copy from blog.ablepear.com.

If you’ve done any Objective-C programming, you’ve seen the NSString literal syntax:

1
2
3
4
5
6
// NSString literal
NSString *name1 = @"Lana Kane";

// creating NSString from a C string literal
NSString *name2 = [NSString stringWithCString:"Sterling Archer"
                                    encoding:NSUTF8StringEncoding];

Continue reading

Administrator Privilege in Mac OS X app

If the Terminal command requires Administrator Privilege (aka sudo), use AuthorizationExecuteWithPrivileges instead. The following will create a file named “com.developers-life.test” is the root directory “/System/Library/Caches”.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
AuthorizationRef authorizationRef;
FILE *pipe = NULL;
OSStatus err = AuthorizationCreate(nil,
                                   kAuthorizationEmptyEnvironment,
                                   kAuthorizationFlagDefaults,
                                   &authorizationRef);

char *command= "/usr/bin/touch";
char *args[] = {"/System/Library/Caches/com.developers-life.test", nil};

err = AuthorizationExecuteWithPrivileges(authorizationRef,
                                         command,
                                         kAuthorizationFlagDefaults,
                                         args,
                                         &pipe);

Extension for safari with savefromnet script

I create extension for safari based on savefrom.net javascript.

Download

About savefrom.net:

SaveFrom.net enables you to get direct download links from more than 40 websites, including RapidShare.com, YouTube.com, Filefactory.com, Vkontakte.ru and many others.

Supported resources:

  • Filehostings:

rapidshare.com, filefactory.com, sendspace.com

  • Mediahostings:

youtube.com, google.com, metacafe.com, break.com, putfile.com, dailymotion.com, vimeo.com, spike.com, sevenload.com, rutube.ru, mail.ru, smotri.com, yandex.ru, rambler.ru, tvigle.ru, intv.ru, vkadre.ru, narod.tv

  • Other sites:

livejournal.com, vkontakte.ru (audio & video), liveinternet.ru (audio & video), myspace.com, guitar-tube.com, gametrailers.com, zaycev.net, tnt-tv.ru, 1tv.ru, rutv.ru, ntv.ru, vesti.ru, mreporter.ru, bibigon.ru, autoplustv.ru, russia.ru, amik.ru, life.ru, a1tv.ru, skillopedia.ru

Posted in Apple
Tagged Extension, , Safari

MAAttachedWindow from Matt Gemmell

Nice window! Thanks, Matt Legend Gemmell! I us it in my apps, good solution! :)



A cool NSWindow subclass which lets you easily attach a view to another window, displayed in a floating “speech-bubble”-like borderless window. Very handy for contextual help, showing options for a certain control, or just to draw attention to things. Have a look at this screenshot to see how it works. You can also grab a project showing how to use an MAAttachedWindow with an NSStatusItem.
Note: this project requires Xcode 2.4 and Mac OS X 10.4 (Tiger) or later, but should work on previous versions of Mac OS X if you include the files in your own project.

Sources Code

Custom message Box

Custom message box on Cocoa, like iOS messsge bubbles!

Continue reading