iOS Development Chat Module--Content Preservation Logic implementation

Source: Internet
Author: User

Detailed Requirements:

In the actual development, it is possible in the late optimization, there will be the need to optimize the needs: Chat input box to save the text entered before, improve the user's good experience.

In the chat module, the user may enter a number of characters in the input box, but do not click to send to exit chat, or to click on the user's avatar to confirm the user's information, or for example, need to send a friend another friend's id have to temporarily quit the current friend chat interface to find another interface for the ID, However, the current chat input box has already entered several characters, and the user certainly does not want to delete the previously typed text after exiting. So here we need to temporarily save the string that the user has typed but not sent out.

However, the need to meet 1, completely kill or completely exit the application needs to clear this temporarily saved string, 2, sent out, must be delegate before the temporary save string.

This part of the logic of the implementation of the first I did not much better clue, only think of local serialization, but actually this is not the best idea, because the local serialization used here a bit of a fuss, in fact, as long as the global static variable dictionary can be.

Concrete implementation of the logic, I also deliberately read the study of the implementation of the coding project, after all, the project is a relatively mature project, chat module is also doing a very good, so learn other people's thoughts, is the so-called standing on the shoulders of giants, is also very good oh.

So below, I will directly read the coding source code in this chat module content Preservation Logic Bar, do not take their own work development projects.

1, first declare the global static variable, coding with inputstrdict to store the input box string, and inputmediadict I do not know what it is specific, it should be media and other elements:

2, then a lot of logic encapsulated in this Uimessageinputview class, methods are not public, the full use of the logic of Uimessageinputview activity cycle can be.

iOS Development Chat Module--Content Preservation Logic implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.