-3

UPDATED This is my code; the last line of code caused the error as described in the title. I understand userDefaults will always return an immutable object; so how do I fix this? I tried making the sending field a "mutable copy" but it was flagged as an error.

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

   if(textField.tag == kStaffName)  {  //  get index of staffName textField
    NSMutableArray *staffNamesArray = [[userDefaults arrayForKey:@"staffNamesArray"] mutableCopy];

    NSInteger indexSelected = [oStaffPickerView selectedRowInComponent:0];

    [staffNamesArray replaceObjectAtIndex:indexSelected withObject:textField.text];
SpokaneDude
  • 4,856
  • 13
  • 64
  • 120

1 Answers1

1

You can try this:

NSMutableArray *staffNamesArray = [[NSMutableArray alloc] initWithArray:[userDefaults arrayForKey:@"staffNamesArray"]];

Hope this help you!

weso
  • 189
  • 3
  • 14