Astuces développement iPhone 5: whatis et ptype

Dans la même veine que le Print Object en console, voici une nouvelle astuce en console de debug. L’idée n’est plus de récupérer la description d’un objet, mais son type. Ainsi, il y a deux commandes: whatis et ptype. La première permets d’avoir simplement le type d’un objet. Ainsi, si on a un objet monDico de type NSMutableDictionary, voilà ce que l’on obtient avec whatis:

(gdb) whatis monDico
type = NSMutableDictionary *

ptype, quant à lui est beaucoup plus complet. Si on reprends le même exemple, voilà ce que l’on obtient:

(gdb) ptype monDico
type = class NSMutableDictionary : public NSDictionary {
} *

Là où ptype prends tout son intérêt, c’est sur les types personnalisés. Voici deux exemple concret avec des objet perso:

(gdb) ptype currentRdv
type = class MiniRdv : public NSObject {
  protected:
    NSString *startDateFormated;
    NSString *startTimeFormated;
    NSString *title;
    NSString *personName;
    NSString *personFirstName;
    NSString *personPhoneBookId;
    NSInteger dbId;
} *
(gdb) ptype cell
type = class RdvTableCell : public UITableViewCell {
  protected:
    MiniRdv *miniRdvObject;
    UILabel *topLeftLabel;
    UILabel *bottomLeftLabel;
    UILabel *bottomRightLabel;
    UILabel *topRightLabel;
    UIImageView *avatar;
} *

Bref, ptype est un outil indispensable au debug d’applications !

Laisser un commentaire

Un nom (requis)

Un mail (requis)

Peut être une URL ?

Réaction:

 

Coins sympas