tailieunhanh - Symbian OS C++ for Mobile Phones VOL 1 PHẦN 3

ViewCmdHitFleet () cho thấy cách điều khiển các mối quan hệ với nhau hai đội tàu được cung cấp bởi động cơ, để iOppFleet của động cơ là những gì tôi nhìn thấy trên màn hình, trong khi iMyFleet của động cơ là các dữ liệu thực sự cho đội tàu của đối phương. khoảng trống CGameController | Access denied if you write the file set its properties to read only using the file manager and then try to write to it again or delete it. R Classes as Member Variables R class objects are often members of a C class object. Assuming that iFs is a member variable of CExampleAppUi the memorymagic delete code could have been written as follows case EMagicCmdDeleteFile User LeaveifError User LeaveifError KTextFileName It s important that CExampleAppUi s C destructor includes a call to iFs. Close so that the RFs is closed even if the delete operation fails. Opening and closing server sessions is relatively expensive so it s better to keep server sessions open for a whole program if you know you re going to need them a lot. We could do this by including the User LeaveIfError in the CExampleAppUi constructL . Then the Delete file handler would become very simple indeed case EMagicCmdDeleteFile User LeaveifError KTextFileName This is a common pattern for using R objects. At the cost of a small amount of memory needed to maintain an open session throughout the lifetime of the application we save having to open and close a session for every operation that uses one. In fact it s so common to need RFs that the CONE environment provides one for you. I could have used case EMagicCmdDeleteFile User LeaveifError iCoeEnv- FsSession .Delete KTextFileName Then I wouldn t have needed to allocate my own RFs at all. It s a very good idea to reuse CONE s RFs since an RFs object uses up significant amounts of memory. Error Code Returns versus L Functions RFs does not provide functions such as ConnectL or DeleteL that would leave with a Tint error code if an error was encountered. Instead it provides Connect and Delete which return a Tint error code including KErrNone if the function returned successfully . This means you have to check errors explicitly using User LeaveIfError which does nothing if its argument is KErrNone

TỪ KHÓA LIÊN QUAN