开发者

Once I delete an object from an array, I need to delete it from another array at the same time. How? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vag开发者_开发知识库ue, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Ive got an app containing contact list, similar to Contacts application. I have all the objects in an array, but I have another array for favourite contacts, which is displayed in another tab. The problem is that once I delete an objects from my contacts array, it stays in the favourites array. Any ideas how can this be solved? It would help a lot. Thanks


As the comments said, your language and array structure would be useful, but I'll try and answer from a "algorithm" perspective.

Your "Favourites" should contain the same objects as in your Contact list (and I assume that object has an ID. If it doesn't, put one in). From there you can say "if I delete from Favourites, simply remove that object from the array". Otherwise, "if I delete from the 'Contacts list' then iteratively remove all the equivalent objects from the other arrays".

Alternatively, if your "Favourites" array simply holds the ID of the contact (and to display it you retrieve the object from the Contact list), then similarly you can delete the number.

Hope this helps, and when you clarify your question more, I'm sure someone will give you a more efficient answer ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜