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