Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using an NSMutableArray to store a struct with data. So I am having problem to get values from NSMutableArray/Struct. Take a look in my code below: ....

{

     NSMutableArray * arrGameControl;
     arrGameControl = [NSMutableArray array];

     //Struct definition
     typedef struct {
      int player; 
      int armaCod;
      int armaID;
      int armaIndex;
      int armaIndexStatus;
      int armaIdOrientacao;
     } sttDataGame;

     //Define the valDados and put values inside struct
     sttDataGame valDados;

     valDados.armaCod=30;
     valDados.armaID=30;
     valDados.armaIdOrientacao=30;
     valDados.armaIndex=30;
     valDados.armaIndexStatus=30;
     valDados.player=30;

     NSLog(@"Valor Inicial :  %d",
        valDados.armaCod);

     //Add rows in my NSMutableArray using struct data
     [ arrGameControl addObject: [NSValue value:&valDados withObjCType:@encode(struct sttDataGame)]];

     //Reset struct values
     valDados.armaCod=0;

     //Here I have a problem
     [[ arrGameControl objectAtIndex:0] getValue:&valDados];

     NSLog(@"%d",valDados.armaCod);

}

..............

What's wrong in this code? Thanks for your attention.

share|improve this question
    
What is the error you're receiving (this looks good and matches other examples found via search) –  KevinDTimm Nov 4 '10 at 14:33
    
Shouldn't encode just be @encode(sttDataGame)? –  Chintan Parikh Nov 4 '13 at 23:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.