YasBES
YasBES

Reputation: 2325

Problem with singleton

i Have singleton

 @interface CartesManager : NSObject {


NSMutableArray *carteMan ; 
NSInteger indexCarteCourante ;
NSInteger numImage ; 
BOOL isEditable ;

}

I want to change the contents of the last cell of the Array "Carteman. I took the last box of the Array.

-(void)DoneButton :(id)sender {

int Valeur ; 

Valeur = ([[CartesManager sharedInstance].carteMan count] -1 );

Carte *uneCarte= [[[CartesManager sharedInstance].carteMan]objectAtIndex:Valeur]; //Expected ":" before ";" token 


 switch (indexsectioncurrent) {
     case 0:
         uneCarte.titre = textField.text ;
         break;
     case 1:
         uneCarte.nom = textField.text ; 
         break;
    case 2:
         uneCarte.prenom = textField.text ; 
        break;
    case 3:
         uneCarte.adresse = textField.text ; 
        break;
    case 4:
         uneCarte.phone = textField.text ; 
        break;
   case 5:
        uneCarte.mobile = textField.text ; 
       break;
   case 6:
        uneCarte.mail = textField.text ; 
       break;
    case 7:
         uneCarte.site = textField.text ; 
        break;
    case 8:
         uneCarte.commentaire = textField.text ; 
        break;

     default:
         break;

 }  
uneCarte.image1 = image1CarteV ; 
uneCarte.image2 = image2CarteV;





[self dismissModalViewControllerAnimated:YES];

}

This is my Problem

         Carte *uneCarte= [[[CartesManager sharedInstance].carteMan]objectAtIndex:Valeur]; //Expected ":" before ";" token** 

Upvotes: 0

Views: 64

Answers (3)

ughoavgfhw
ughoavgfhw

Reputation: 39905

When you go through the line causing the error in the order of execution, this is what happens:

  1. [CartesManager sharedInstance]; This returns a CartesManager object
  2. result.carteMan; This takes the result of the first step and gets the property named carteMan, returning an NSMutableArray object
  3. [result]; This is an incomplete message. It has a receiver, but no command. I don't think you want to perform this step at all, as it appears the you want to call objectAtIndex: on the array from step 2.

To fix your problem, change your code from

Carte *uneCarte= [[[CartesManager sharedInstance].carteMan]objectAtIndex:Valeur];

to

Carte *uneCarte= [[CartesManager sharedInstance].carteMan objectAtIndex:Valeur];

Upvotes: 1

SVD
SVD

Reputation: 4753

Don't need [] when accessing a property:

Carte *uneCarte= [[CartesManager sharedInstance].carteMan objectAtIndex:Valeur]; 

Upvotes: 5

Caleb
Caleb

Reputation: 124997

For starters, put a space between the .carteMan] and objectAtIndex:. Also, it's not clear that you've declared carteMan to be a property. You may need to add:

@property(retain, nonatomic) NSMutableArray *carteMan;

to your header file, and:

@synthesize carteMan;

to your implementation file.

Upvotes: 1

Related Questions