What’s coming for Leopard

leopard.jpg

All the fellowing informations are found in the WWDC 2006 state of she union conference that was firstmade available to ADC Online (registration is free) members the last week. Most of the items I’ll enumerate are not new for the ones that fellow the Apple actuality, but it’s good to see them all in one place and confirmed directly from Apple.

  • Not only the Unix layer but also the graphics, frameworks and Aqua are now 64 bits
  • New features to ease the use of multi-core machines (NSOperation & NSOperationQueue)
  • Objective-C will now have a garbage collection (the old reference counting can still be used)
  • Open-GL comes now in a multi-threaded fashion
  • Core Animation is improved with implicit animations and NSGridView (you have to see it to beleive it)
  • OS 10.5 will be resolution independant
  • Spotlight can now searche through the network
  • New system of preview that allows developers to chose what kind of preview a document should have (the same principle as for preview icons that are generated for pictures)
  • New system of help where not only the search explains you how to do things but also open the right menu for you
  • Time machine with its incremental backup

I must say that after looking at the video I wonder if I’m not goint to buy an ADC Select membership. I don’t know if Apple provide this video just to sell more ADC membership, if it was to make buzz around Leopard just when Vista is coming or for any other reasons that I can’t imagine, but I must admit that the quality of the stuff provided is amazing.

nil, Nil and NULL what’s the difference?

If you use GCC, you will most probably never ever see a difference between this 3 keywords and can use them interchangeably. If you use another compiler, if you just wonder or if you care about writing semantically correct code then just keep reading.

  • nil is a null object pointer, (id)0 [that is the number 0 casted to the type id]
  • Nil is a null class pointer, (Class)0 [that is the number 0 casted to the type Class]
  • NULL is a null pointer constant, (void *)0 [it’s a preprocessor macro defined by ANSI C]

Then be carefull to use only nil whith object and not with a numerical primitive type. Otherwise you could have some unpleasant suprises.
Source for Objective-C and for ANSI C, NULL is standardly defined in stddef.h

How to use Predefined Header

Did you ever wonder what was this single file called [YourProjectName]_Prefix.pch.

prefix_pch.jpg

Sure this look like a perfectly well formed Objective-C header, but did you ever try, for example, to use the #define precompiler directive in this file and then using the predefined keyword in one of your project’s classes. No Luck hey, it seems that this header is never read. Sound bizzare isn’t it.

The answer is simply that, for a reason I can’t understand Apple , just forgot to configure properly the project template. Then we have to do it by ourself. Just go to the Project menu and then select the Edit Active Target ‘[YourProjectName](see below).
menu.jpg

Finally correct the two Prefix build options such that it looks like below.
target_info.jpg

Now you’re done, enjoy the use of the centralized header.

It seems also possible to modify the template in order to have this options directly set. CocoaDev seems to be a good starting point for further investigations on the subject.

Regular Expressions in Objective-C

This class allows you to use very powerfull regular expressions (because it’s based on regexec from C) in an object oriented way.
Thanks to the post of David Teare, I finally find a very easy and powerfull solution for using regular expressions in Objective-C. David’s code only returns a boolean to indicate if the NSString was matching the given regular expression. I improve its method by returning a NSMutableArray with the different sub-expressions that lead to a match. Unfortunately I wasn’t able to return nil when the sub-expression doesn’t produce a match, instead I return the empty NSString @””.

Download Regular Expression Source Code

[Updated the 16.05.2007] Thanks to everybody for you remarks, I updated the source file accordingly. I also add a example script to demonstrate the use of the method.

Download Regular Expression Source Code version 1.1

[Updated the 01.01.2008] After receiving a reader’s mail about the code’s licencing, I clarify the situation and add the GPL licence in the header as well as the full licence in the package.

Download  Regular Expression Source Code version 1.1

[Update 22.02.2009] Hey I just discovered that TwitterFon, YMail and swisssms are using this class. Cool isn’t it.

[Updated the 08.04.2009] Bugfix the behavior when working on NSString with UTF8 encoded chars. Thanks to Ian Atha & soniccat for the correction

Download Regular Expression Source Code version 1.2