I'm currently traducing the posts in english, my english is not very good, so if you find errors feel free to contact me.
  • Improving NSLog()

    When you debug an app, you often need to print informations on screen to check out if everything is ok etc… But when you are done and you are ready to release your application it’s a real pain in the ass to comment or remove all the call to these functions, plus they might be useful later.
    To fix this problem you just need to define a macro that indicates if you are in a debug phase or not, if it’s the case informations will be printed on the screen otherwise nothing will happen.
    Not so long age I found a article who just talk about this, and in the end a code was proposed :

    1
    2
    3
    4
    5
    6
    
    #ifdef DEBUG
    #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
    #else
    #define DLog(...)
    #endif
    #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

    Place this code in the [PROJECT_NAME]_Prefix.pch file, and it’s almost done ;)

    The macro DLog() works exaclty like NSLog(), so you can pass arguments etc… the advantage is that the line and the function name will be printed thanks to __PRETTY_FUNCTION__ & __LINE__ macros.
    As for the macro ALog(), it remplaces NSLog() and will always produce an output.

    The last thing you have to do is to define the DEBUG macro. In XCode go to project information, chose Debug configuration and in the Preprocessing part look for the line Preprocessor Macros and add it :

    1
    
    DEBUG=1

    See ya!


  • SLNTFS 1.0b1

    Suite à l’angouement sucité par mon dernier post, je me suis dit que j’allais coder une Préférence Pane pour automatiser ça, d’autant plus que pleins de personnes éditent le fichier fstab.hd au lieu de fstab et s’étonnent que ça ne marche pas !
    Je ne suis pas fan de Cocoa, mais bon j’avais jamais testé de coder une PrefPane, c’était l’occaz, et je dois avouer que c’était assez sympas à coder :)

    Je vous présente donc une première version beta de cet utilitaire que j’ai nommé SL-NTFS.
    Comment ça marche ?

    j’ai essayé de faire au plus simple, lorsque la préférence est ouverte, la liste des volumes NTFS disponibles est affichée avec leurs UUID et le status pour indiquer si l’écriture sur ce volume est activée.

    Il suffit juste de cocher ou décocher la case pour changer l’autorisation d’écriture, le mot de passe admin sera alors demandé pour effectuer la modification.
    Hop c’est magique ça marche (ou pas), et aucun reboot n’est nécessaire :)

    Si le disque est externe, il faut le brancher avant d’ouvrir la préférence, j’assaye de voir comment gérer ça du côté de I/O Kit..

    Pour l’install :
    - Décompresser le .zip.
    - Copier le fichier SLNTFS.prefPane dans ~/Bibliothèque/PreferencePanes/

    Télécharger SL-NTFS 1.0b1