Shoaib Ahmed
Shoaib Ahmed

Reputation: 424

Array last inserted/deleted item

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

Answers (3)

xcodeGeek
xcodeGeek

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

KRUBERLICK
KRUBERLICK

Reputation: 1

You can simply create a variable and update it every time you insert/delete.

Upvotes: 0

rob mayoff
rob mayoff

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

Related Questions