2009 Archives

Note: If the @ symbol before the quotes in @"The number at index %d is %@" looks a little strange, remember that Objective-C is the C language with a couple of extensions. One of the extensions is that strings are instances of the class NSString. In C, strings are simply pointers to a buffer of characters that ends in the null character. Both C strings and instances of NSString can be used in the same file. To differentiate between constant C strings and constant NSStrings, you must put @ before the opening quote of a constant NSString:

// C string
char *foo;
// NSString
NSString *bar;
foo = "this is a C string";
bar = @"this is an NSString";

You will use mostly NSString in Cocoa programming. Wherever a string is needed, the classes in the frameworks expect an NSString. However, if you already have a bunch of C functions that expect C strings, you will find yourself using char * frequently.

You can convert between C strings and NSStrings:

const char *foo = "Blah blah";
NSString *bar;
// Create an NSString from a C string
bar = [NSString stringWithUTF8String:foo];

// Create a C string from an NSString
foo = [bar UTF8String];

Because NSString can hold Unicode strings, you will need to deal with the multibyte characters correctly in your C strings, and this can be quite difficult and time consuming. (Besides the multibyte problem, you will have to wrestle with the fact that some languages read from right to left.) Whenever possible, you should use NSString instead of C strings.

objC re test code

| No Comments | No TrackBacks
objc-re.jpg

reboot的时候出了点小问题ZZ
FreeBSD bsdx64 7.1-STABLE FreeBSD 7.1-STABLE #0: Fri Jan  9 13:46:43 CST 2009     root@bsdx64:/usr/obj/software/FreeBSD/src/sys/GW  amd64

root@bsdx64]#w
5:08下午  up 108 days, 20:42, 1 user, load averages: 0.01, 0.02, 0.00
USER             TTY      FROM              LOGIN@  IDLE WHAT
yarshure         p0       61.129.60.82      4:12丠    - w

last pid: 62908;  load averages:  0.04,  0.03,  0.00                                                       up 108+20:41:20 17:07:15
77 processes:  1 running, 75 sleeping, 1 zombie
CPU: 21.8% user,  0.0% nice,  2.8% system,  0.0% interrupt, 75.4% idle
Mem: 309M Active, 2526M Inact, 291M Wired, 200M Cache, 214M Buf, 2614M Free
Swap: 2048M Total, 2048M Free

Apple Keynotes

| No Comments | No TrackBacks

The Apple Keynotes podcast offers video of the company's most important announcements, including Apple CEO Steve Job's annual keynotes from Macworld.
包含以下Keynote Address 下载连接
    Macworld San Francisco 2009 Keynote Address
    Apple Special Event, October 2008
    Apple Special Event, September 2008
    WWDC 2008 Keynote Address
    Apple March 6 Event: iPhone Software Roadmap
    Macworld San Francisco 2008 Keynote Address
    Macworld San Francisco 2007 Keynote Address

http://www.apple.com/podcasts/apple_keynotes/apple_keynotes.xml

更新图片一张

| No Comments | No TrackBacks
2008.jpg
yarshure@MacGeeks.cn