Hey quick question. I have a plist that I am unpacking to add an object and re save.
It's the objects I need will always be at the last index so I can use "LastObject" Task from the Array class to perform that. But when I add an object to a dict and want to replace the dict that is saved at the last index of the Array I need the index number to replace that index.
The way I have been doing it is to just get the count of the Array then -1 to find the last index to write to. I was just wondering if anyone new a short cut that I can write to the lastObject just as easy as I retrieve from it.
I am not stuck and my method works just fine, I was just wondering?
Thanks
Code:
NSMutableArray *exerArray = [[NSMutableArray alloc] initWithContentsOfFile:[bpc returnPath:@"exerciseLog.plist"]];
NSMutableDictionary *exerDict = [NSMutableDictionary dictionaryWithDictionary:[exerArray lastObject]];
[exerDict setValue: totalCalLabel.text forKey: itemNameTextField.text];
It's the objects I need will always be at the last index so I can use "LastObject" Task from the Array class to perform that. But when I add an object to a dict and want to replace the dict that is saved at the last index of the Array I need the index number to replace that index.
The way I have been doing it is to just get the count of the Array then -1 to find the last index to write to. I was just wondering if anyone new a short cut that I can write to the lastObject just as easy as I retrieve from it.
I am not stuck and my method works just fine, I was just wondering?
Thanks