favorites = [[NSMutableArray alloc] init];
for (int i=0; i<9; i++) {
[favorites addObject:[[[Favorite alloc] constructUnknown] autorelease]];
}
je reçois:tableau de remplissage C avec des pointeurs de classe personnalisée
Mettre fin application en raison d'une exception non interceptée 'NSInvalidArgumentException', raison: « *** - [Favorite Taille]: sélecteur non reconnu envoyé à l'instance 0x380d9c0 '
pourquoi?
favori est ma classe personnalisée, favoris un tableau contenant 9 cas de ma classe personnalisée
modifier:
Favorite.h:
-(Favorite*)constructUnknown;
Favorite.m:
- (Favorite*)constructUnknown{
self=[super init];
if (self) {
image=[UIImage imageNamed:@"unknown.png"];
}
return self;
}
FAVORIS COMPLETS.h
@interface Favorite : NSObject {
NSString *identity;
bool ready;
UIImage *image;
NSURL *telephone;
}
@property (nonatomic,retain) UIImage *image;
@property (nonatomic,retain) NSURL *telephone;
@property (nonatomic,retain) NSString *identity;
//passare unknown al nome per costrutire un oggetto unknown.
-(Favorite*)constructWithID:(NSString*)name withPhoto:(UIImage*)photo andNumber:(NSString*)number;
-(Favorite*)constructUnknown;
-(NSURL*) convertToUrl:(NSString*)phone;
- (UIImage*) getImage;
@end
Comment définir '-constructUnknown'? – kennytm
J'ai testé le constructeur sur un seul pointeur: ça marche –
Montrez-nous Favorite.h? Je suis curieux de savoir si vous avez correctement sous-classé NSObject. –