Reputation: 424
How can I get the last inserted/deleted item from an array?
Is there any such built-in property?
I would be inserting/deleting using indices so array.last
is not what I need.
Upvotes: 0
Views: 82
Reputation: 1
if you want to get the last object of the array
you can use the count of that array
.
if i have a array
named integerArray
i have inserted some objects than to get the last object .
int LastObject=[integerArray objectAtIndex:integerArray.count -1]intValue];
Upvotes: -1
Reputation: 1
You can simply create a variable and update it every time you insert/delete.
Upvotes: 0
Reputation: 385670
No, there is no such built-in property. An array doesn't keep any history of the specific operations that resulted in its value. You must track it yourself if you need it.
Upvotes: 2